@@ -28,47 +28,59 @@ public function testPassByResolverIfGivenIp()
2828 $ this ->resolver ->expects ($ this ->never ())->method ('resolve ' );
2929 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('127.0.0.1:80 ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
3030
31- $ this ->connector ->connect ('127.0.0.1:80 ' );
31+ $ promise = $ this ->connector ->connect ('127.0.0.1:80 ' );
32+
33+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
3234 }
3335
3436 public function testPassThroughResolverIfGivenHost ()
3537 {
3638 $ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
3739 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=google.com ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
3840
39- $ this ->connector ->connect ('google.com:80 ' );
41+ $ promise = $ this ->connector ->connect ('google.com:80 ' );
42+
43+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
4044 }
4145
4246 public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6 ()
4347 {
4448 $ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('::1 ' )));
4549 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('[::1]:80?hostname=google.com ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
4650
47- $ this ->connector ->connect ('google.com:80 ' );
51+ $ promise = $ this ->connector ->connect ('google.com:80 ' );
52+
53+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
4854 }
4955
5056 public function testPassByResolverIfGivenCompleteUri ()
5157 {
5258 $ this ->resolver ->expects ($ this ->never ())->method ('resolve ' );
5359 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('scheme://127.0.0.1:80/path?query#fragment ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
5460
55- $ this ->connector ->connect ('scheme://127.0.0.1:80/path?query#fragment ' );
61+ $ promise = $ this ->connector ->connect ('scheme://127.0.0.1:80/path?query#fragment ' );
62+
63+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
5664 }
5765
5866 public function testPassThroughResolverIfGivenCompleteUri ()
5967 {
6068 $ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
6169 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('scheme://1.2.3.4:80/path?query&hostname=google.com#fragment ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
6270
63- $ this ->connector ->connect ('scheme://google.com:80/path?query#fragment ' );
71+ $ promise = $ this ->connector ->connect ('scheme://google.com:80/path?query#fragment ' );
72+
73+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
6474 }
6575
6676 public function testPassThroughResolverIfGivenExplicitHost ()
6777 {
6878 $ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
6979 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('scheme://1.2.3.4:80/?hostname=google.de ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
7080
71- $ this ->connector ->connect ('scheme://google.com:80/?hostname=google.de ' );
81+ $ promise = $ this ->connector ->connect ('scheme://google.com:80/?hostname=google.de ' );
82+
83+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
7284 }
7385
7486 public function testRejectsImmediatelyIfUriIsInvalid ()
@@ -289,6 +301,9 @@ public function testRejectionDuringDnsLookupShouldNotCreateAnyGarbageReferences(
289301 $ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
290302
291303 $ promise = $ this ->connector ->connect ('example.com:80 ' );
304+
305+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
306+
292307 $ dns ->reject (new \RuntimeException ('DNS failed ' ));
293308 unset($ promise , $ dns );
294309
@@ -310,6 +325,9 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferences()
310325 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
311326
312327 $ promise = $ this ->connector ->connect ('example.com:80 ' );
328+
329+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
330+
313331 $ dns ->resolve ('1.2.3.4 ' );
314332 $ tcp ->reject (new \RuntimeException ('Connection failed ' ));
315333 unset($ promise , $ dns , $ tcp );
@@ -335,6 +353,9 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferencesAg
335353 $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
336354
337355 $ promise = $ this ->connector ->connect ('example.com:80 ' );
356+
357+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
358+
338359 $ dns ->resolve ('1.2.3.4 ' );
339360
340361 unset($ promise , $ dns , $ tcp );
0 commit comments