@@ -80,14 +80,18 @@ public function testConnectWillRejectWithTlsUriWhenUnderlyingConnectorRejects()
8080 )));
8181
8282 $ promise = $ this ->connector ->connect ('example.com:80 ' );
83- $ promise ->cancel ();
8483
85- $ this ->setExpectedException (
86- 'RuntimeException ' ,
87- 'Connection to tls://example.com:80 failed: Connection refused (ECONNREFUSED) ' ,
88- defined ('SOCKET_ECONNREFUSED ' ) ? SOCKET_ECONNREFUSED : 111
89- );
90- $ this ->throwRejection ($ promise );
84+ $ exception = null ;
85+ $ promise ->then (null , function ($ reason ) use (&$ exception ) {
86+ $ exception = $ reason ;
87+ });
88+
89+ assert ($ exception instanceof \RuntimeException);
90+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
91+ $ this ->assertEquals ('Connection to tls://example.com:80 failed: Connection refused (ECONNREFUSED) ' , $ exception ->getMessage ());
92+ $ this ->assertEquals (defined ('SOCKET_ECONNREFUSED ' ) ? SOCKET_ECONNREFUSED : 111 , $ exception ->getCode ());
93+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception ->getPrevious ());
94+ $ this ->assertNotEquals ('' , $ exception ->getTraceAsString ());
9195 }
9296
9397 public function testConnectWillRejectWithOriginalMessageWhenUnderlyingConnectorRejectsWithInvalidArgumentException ()
@@ -128,12 +132,17 @@ public function testCancelDuringTcpConnectionCancelsTcpConnectionAndRejectsWithT
128132 $ promise = $ this ->connector ->connect ('example.com:80 ' );
129133 $ promise ->cancel ();
130134
131- $ this ->setExpectedException (
132- 'RuntimeException ' ,
133- 'Connection to tls://example.com:80 cancelled (ECONNABORTED) ' ,
134- defined ('SOCKET_ECONNABORTED ' ) ? SOCKET_ECONNABORTED : 103
135- );
136- $ this ->throwRejection ($ promise );
135+ $ exception = null ;
136+ $ promise ->then (null , function ($ reason ) use (&$ exception ) {
137+ $ exception = $ reason ;
138+ });
139+
140+ assert ($ exception instanceof \RuntimeException);
141+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
142+ $ this ->assertEquals ('Connection to tls://example.com:80 cancelled (ECONNABORTED) ' , $ exception ->getMessage ());
143+ $ this ->assertEquals (defined ('SOCKET_ECONNABORTED ' ) ? SOCKET_ECONNABORTED : 103 , $ exception ->getCode ());
144+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception ->getPrevious ());
145+ $ this ->assertNotEquals ('' , $ exception ->getTraceAsString ());
137146 }
138147
139148 public function testConnectionWillBeClosedAndRejectedIfConnectionIsNoStream ()
0 commit comments