@@ -107,17 +107,13 @@ public function testStreamEncryptionWillBeEnabledAfterConnecting()
107107 $ promise = $ this ->connector ->connect ('example.com:80 ' );
108108 }
109109
110- /**
111- * @expectedException RuntimeException
112- * @expectedExceptionMessage Connection to example.com:80 failed during TLS handshake: TLS error
113- */
114110 public function testConnectionWillBeRejectedIfStreamEncryptionFailsAndClosesConnection ()
115111 {
116112 $ connection = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->getMock ();
117113 $ connection ->expects ($ this ->once ())->method ('close ' );
118114
119115 $ encryption = $ this ->getMockBuilder ('React\Socket\StreamEncryption ' )->disableOriginalConstructor ()->getMock ();
120- $ encryption ->expects ($ this ->once ())->method ('enable ' )->willReturn (Promise \reject (new \RuntimeException ('TLS error ' )));
116+ $ encryption ->expects ($ this ->once ())->method ('enable ' )->willReturn (Promise \reject (new \RuntimeException ('TLS error ' , 123 )));
121117
122118 $ ref = new \ReflectionProperty ($ this ->connector , 'streamEncryption ' );
123119 $ ref ->setAccessible (true );
@@ -128,7 +124,13 @@ public function testConnectionWillBeRejectedIfStreamEncryptionFailsAndClosesConn
128124
129125 $ promise = $ this ->connector ->connect ('example.com:80 ' );
130126
131- $ this ->throwRejection ($ promise );
127+ try {
128+ $ this ->throwRejection ($ promise );
129+ } catch (\RuntimeException $ e ) {
130+ $ this ->assertEquals ('Connection to example.com:80 failed during TLS handshake: TLS error ' , $ e ->getMessage ());
131+ $ this ->assertEquals (123 , $ e ->getCode ());
132+ $ this ->assertNull ($ e ->getPrevious ());
133+ }
132134 }
133135
134136 /**
0 commit comments