@@ -26,49 +26,49 @@ 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
- $ this ->connector ->connect ('127.0.0.1:80 ' );
31
+ $ this ->connector ->connect ('127.0.0.1:80 ' )-> then ( null , function () {}) ;
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
- $ this ->connector ->connect ('google.com:80 ' );
39
+ $ this ->connector ->connect ('google.com:80 ' )-> then ( null , function () {}) ;
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
- $ this ->connector ->connect ('google.com:80 ' );
47
+ $ this ->connector ->connect ('google.com:80 ' )-> then ( null , function () {}) ;
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
- $ this ->connector ->connect ('scheme://127.0.0.1:80/path?query#fragment ' );
55
+ $ this ->connector ->connect ('scheme://127.0.0.1:80/path?query#fragment ' )-> then ( null , function () {}) ;
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
- $ this ->connector ->connect ('scheme://google.com:80/path?query#fragment ' );
63
+ $ this ->connector ->connect ('scheme://google.com:80/path?query#fragment ' )-> then ( null , function () {}) ;
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
- $ this ->connector ->connect ('scheme://google.com:80/?hostname=google.de ' );
71
+ $ this ->connector ->connect ('scheme://google.com:80/?hostname=google.de ' )-> then ( null , function () {}) ;
72
72
}
73
73
74
74
public function testRejectsImmediatelyIfUriIsInvalid ()
@@ -134,7 +134,7 @@ public function testRejectionExceptionUsesPreviousExceptionIfDnsFails()
134
134
135
135
public function testCancelDuringDnsCancelsDnsAndDoesNotStartTcpConnection ()
136
136
{
137
- $ pending = new Promise \Promise (function () { }, $ this -> expectCallableOnce () );
137
+ $ pending = new Promise \Promise (function () { }, function () { } );
138
138
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('example.com ' ))->will ($ this ->returnValue ($ pending ));
139
139
$ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
140
140
@@ -157,7 +157,7 @@ public function testCancelDuringTcpConnectionCancelsTcpConnectionIfGivenIp()
157
157
158
158
public function testCancelDuringTcpConnectionCancelsTcpConnectionAfterDnsIsResolved ()
159
159
{
160
- $ pending = new Promise \Promise (function () { }, $ this -> expectCallableOnce () );
160
+ $ pending = new Promise \Promise (function () { }, function () { } );
161
161
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('example.com ' ))->willReturn (Promise \resolve ('1.2.3.4 ' ));
162
162
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ pending );
163
163
@@ -196,7 +196,7 @@ public function testRejectionDuringDnsLookupShouldNotCreateAnyGarbageReferences(
196
196
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('example.com ' ))->willReturn ($ dns ->promise ());
197
197
$ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
198
198
199
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
199
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
200
200
$ dns ->reject (new \RuntimeException ('DNS failed ' ));
201
201
unset($ promise , $ dns );
202
202
@@ -217,7 +217,7 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferences()
217
217
$ tcp = new Deferred ();
218
218
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
219
219
220
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
220
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
221
221
$ dns ->resolve ('1.2.3.4 ' );
222
222
$ tcp ->reject (new \RuntimeException ('Connection failed ' ));
223
223
unset($ promise , $ dns , $ tcp );
@@ -242,7 +242,7 @@ public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferencesAg
242
242
});
243
243
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp ->promise ());
244
244
245
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
245
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
246
246
$ dns ->resolve ('1.2.3.4 ' );
247
247
248
248
unset($ promise , $ dns , $ tcp );
@@ -264,7 +264,7 @@ public function testCancelDuringDnsLookupShouldNotCreateAnyGarbageReferences()
264
264
$ this ->resolver ->expects ($ this ->once ())->method ('resolve ' )->with ($ this ->equalTo ('example.com ' ))->willReturn ($ dns ->promise ());
265
265
$ this ->tcp ->expects ($ this ->never ())->method ('connect ' );
266
266
267
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
267
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( null , function () { }) ;
268
268
269
269
$ promise ->cancel ();
270
270
unset($ promise , $ dns );
@@ -287,7 +287,7 @@ public function testCancelDuringTcpConnectionShouldNotCreateAnyGarbageReferences
287
287
});
288
288
$ this ->tcp ->expects ($ this ->once ())->method ('connect ' )->with ($ this ->equalTo ('1.2.3.4:80?hostname=example.com ' ))->willReturn ($ tcp );
289
289
290
- $ promise = $ this ->connector ->connect ('example.com:80 ' );
290
+ $ promise = $ this ->connector ->connect ('example.com:80 ' )-> then ( function () { }, function () { }) ;
291
291
$ dns ->resolve ('1.2.3.4 ' );
292
292
293
293
$ promise ->cancel ();
0 commit comments