@@ -107,17 +107,13 @@ public function testStreamEncryptionWillBeEnabledAfterConnecting()
107
107
$ promise = $ this ->connector ->connect ('example.com:80 ' );
108
108
}
109
109
110
- /**
111
- * @expectedException RuntimeException
112
- * @expectedExceptionMessage Connection to example.com:80 failed during TLS handshake: TLS error
113
- */
114
110
public function testConnectionWillBeRejectedIfStreamEncryptionFailsAndClosesConnection ()
115
111
{
116
112
$ connection = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->getMock ();
117
113
$ connection ->expects ($ this ->once ())->method ('close ' );
118
114
119
115
$ 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 )));
121
117
122
118
$ ref = new \ReflectionProperty ($ this ->connector , 'streamEncryption ' );
123
119
$ ref ->setAccessible (true );
@@ -128,7 +124,13 @@ public function testConnectionWillBeRejectedIfStreamEncryptionFailsAndClosesConn
128
124
129
125
$ promise = $ this ->connector ->connect ('example.com:80 ' );
130
126
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
+ }
132
134
}
133
135
134
136
/**
0 commit comments