@@ -26,47 +26,47 @@ public function setUpMocks()
26
26
public function testPassByResolverIfGivenIp ()
27
27
{
28
28
$ this ->resolver ->expects ($ this ->never ())->method ('resolve ' );
29
- $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('127.0.0.1:80 ' ))->will ($ this ->returnValue (Promise \reject ()));
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
31
$ this ->connector ->connect ('127.0.0.1:80 ' );
32
32
}
33
33
34
34
public function testPassThroughResolverIfGivenHost ()
35
35
{
36
36
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
37
- $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=google.com ' ))->will ($ this ->returnValue (Promise \reject ()));
37
+ $ 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
38
39
39
$ this ->connector ->connect ('google.com:80 ' );
40
40
}
41
41
42
42
public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6 ()
43
43
{
44
44
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('::1 ' )));
45
- $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('[::1]:80?hostname=google.com ' ))->will ($ this ->returnValue (Promise \reject ()));
45
+ $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('[::1]:80?hostname=google.com ' ))->will ($ this ->returnValue (Promise \reject (new \ Exception ( ' reject ' ) )));
46
46
47
47
$ this ->connector ->connect ('google.com:80 ' );
48
48
}
49
49
50
50
public function testPassByResolverIfGivenCompleteUri ()
51
51
{
52
52
$ this ->resolver ->expects ($ this ->never ())->method ('resolve ' );
53
- $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('scheme://127.0.0.1:80/path?query#fragment ' ))->will ($ this ->returnValue (Promise \reject ()));
53
+ $ 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
54
55
55
$ this ->connector ->connect ('scheme://127.0.0.1:80/path?query#fragment ' );
56
56
}
57
57
58
58
public function testPassThroughResolverIfGivenCompleteUri ()
59
59
{
60
60
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
61
- $ 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 ()));
61
+ $ 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
62
63
63
$ this ->connector ->connect ('scheme://google.com:80/path?query#fragment ' );
64
64
}
65
65
66
66
public function testPassThroughResolverIfGivenExplicitHost ()
67
67
{
68
68
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('google.com ' ))->will ($ this ->returnValue (Promise \resolve ('1.2.3.4 ' )));
69
- $ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('scheme://1.2.3.4:80/?hostname=google.de ' ))->will ($ this ->returnValue (Promise \reject ()));
69
+ $ 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
70
71
71
$ this ->connector ->connect ('scheme://google.com:80/?hostname=google.de ' );
72
72
}
@@ -288,7 +288,7 @@ public function testRejectionDuringDnsLookupShouldNotCreateAnyGarbageReferences(
288
288
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('example.com ' ))->willReturn ($ dns ->promise ());
289
289
$ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
290
290
291
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
291
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
292
292
$ dns ->reject (new \RuntimeException ('DNS failed ' ));
293
293
unset($ promise , $ dns );
294
294
@@ -309,7 +309,7 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferences()
309
309
$ tcp = new Deferred ();
310
310
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
311
311
312
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
312
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
313
313
$ dns ->resolve ('1.2.3.4 ' );
314
314
$ tcp ->reject (new \RuntimeException ('Connection failed ' ));
315
315
unset($ promise , $ dns , $ tcp );
@@ -334,7 +334,7 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferencesAg
334
334
});
335
335
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
336
336
337
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
337
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
338
338
$ dns ->resolve ('1.2.3.4 ' );
339
339
340
340
unset($ promise , $ dns , $ tcp );
@@ -356,7 +356,7 @@ public function testCancelDuringDnsLookupShouldNotCreateAnyGarbageReferences()
356
356
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('example.com ' ))->willReturn ($ dns ->promise ());
357
357
$ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
358
358
359
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
359
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
360
360
361
361
$ promise ->cancel ();
362
362
unset($ promise , $ dns );
@@ -379,7 +379,7 @@ public function testCancelDuringTcpConnectionShouldNotCreateAnyGarbageReferences
379
379
});
380
380
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp );
381
381
382
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
382
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( function () { }, function () { }) ;
383
383
$ dns ->resolve ('1.2.3.4 ' );
384
384
385
385
$ promise ->cancel ();
0 commit comments