@@ -28,47 +28,59 @@ public function testPassByResolverIfGivenIp()
28
28
$ this ->resolver ->expects ($ this ->never ())->method ('resolve ' );
29
29
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('127.0.0.1:80 ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
30
30
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
32
34
}
33
35
34
36
public function testPassThroughResolverIfGivenHost ()
35
37
{
36
38
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
37
39
$ 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 ' ))));
38
40
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
40
44
}
41
45
42
46
public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6 ()
43
47
{
44
48
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('::1 ' )));
45
49
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('[::1]:80?hostname=google.com ' ))->will ($ this ->returnValue (Promise \reject (new \Exception ('reject ' ))));
46
50
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
48
54
}
49
55
50
56
public function testPassByResolverIfGivenCompleteUri ()
51
57
{
52
58
$ this ->resolver ->expects ($ this ->never ())->method ('resolve ' );
53
59
$ 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 ' ))));
54
60
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
56
64
}
57
65
58
66
public function testPassThroughResolverIfGivenCompleteUri ()
59
67
{
60
68
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
61
69
$ 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 ' ))));
62
70
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
64
74
}
65
75
66
76
public function testPassThroughResolverIfGivenExplicitHost ()
67
77
{
68
78
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
69
79
$ 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 ' ))));
70
80
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
72
84
}
73
85
74
86
public function testRejectsImmediatelyIfUriIsInvalid ()
@@ -289,6 +301,9 @@ public function testRejectionDuringDnsLookupShouldNotCreateAnyGarbageReferences(
289
301
$ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
290
302
291
303
$ promise = $ this ->connector ->connect ('example.com:80 ' );
304
+
305
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
306
+
292
307
$ dns ->reject (new \RuntimeException ('DNS failed ' ));
293
308
unset($ promise , $ dns );
294
309
@@ -310,6 +325,9 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferences()
310
325
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
311
326
312
327
$ promise = $ this ->connector ->connect ('example.com:80 ' );
328
+
329
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
330
+
313
331
$ dns ->resolve ('1.2.3.4 ' );
314
332
$ tcp ->reject (new \RuntimeException ('Connection failed ' ));
315
333
unset($ promise , $ dns , $ tcp );
@@ -335,6 +353,9 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferencesAg
335
353
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
336
354
337
355
$ promise = $ this ->connector ->connect ('example.com:80 ' );
356
+
357
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
358
+
338
359
$ dns ->resolve ('1.2.3.4 ' );
339
360
340
361
unset($ promise , $ dns , $ tcp );
0 commit comments