Skip to content

Commit a274edb

Browse files
committed
Forward compatibility with react/promise 3
1 parent 28fac70 commit a274edb

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
3131
"react/dns": "^1.1",
3232
"react/event-loop": "^1.0 || ^0.5",
33-
"react/promise": "^2.6.0 || ^1.2.1",
33+
"react/promise": "dev-master as 2.999.9999",
3434
"react/promise-timer": "^1.4.0",
3535
"react/stream": "^1.1"
3636
},

tests/DnsConnectorTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,47 @@ public function setUpMocks()
2626
public function testPassByResolverIfGivenIp()
2727
{
2828
$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'))));
3030

3131
$this->connector->connect('127.0.0.1:80');
3232
}
3333

3434
public function testPassThroughResolverIfGivenHost()
3535
{
3636
$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'))));
3838

3939
$this->connector->connect('google.com:80');
4040
}
4141

4242
public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6()
4343
{
4444
$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'))));
4646

4747
$this->connector->connect('google.com:80');
4848
}
4949

5050
public function testPassByResolverIfGivenCompleteUri()
5151
{
5252
$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'))));
5454

5555
$this->connector->connect('scheme://127.0.0.1:80/path?query#fragment');
5656
}
5757

5858
public function testPassThroughResolverIfGivenCompleteUri()
5959
{
6060
$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'))));
6262

6363
$this->connector->connect('scheme://google.com:80/path?query#fragment');
6464
}
6565

6666
public function testPassThroughResolverIfGivenExplicitHost()
6767
{
6868
$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'))));
7070

7171
$this->connector->connect('scheme://google.com:80/?hostname=google.de');
7272
}

tests/HappyEyeBallsConnectorTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testPassByResolverIfGivenIp()
8484
public function testPassByResolverIfGivenIpv6()
8585
{
8686
$this->resolver->expects($this->never())->method('resolveAll');
87-
$this->tcp->expects($this->once())->method('connect')->with($this->equalTo('[::1]:80'))->will($this->returnValue(Promise\reject()));
87+
$this->tcp->expects($this->once())->method('connect')->with($this->equalTo('[::1]:80'))->will($this->returnValue(Promise\reject(new \Exception('reject'))));
8888

8989
$this->connector->connect('[::1]:80');
9090

@@ -94,7 +94,7 @@ public function testPassByResolverIfGivenIpv6()
9494
public function testPassThroughResolverIfGivenHost()
9595
{
9696
$this->resolver->expects($this->exactly(2))->method('resolveAll')->with($this->equalTo('google.com'), $this->anything())->will($this->returnValue(Promise\resolve(array('1.2.3.4'))));
97-
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('1.2.3.4:80?hostname=google.com'))->will($this->returnValue(Promise\reject()));
97+
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('1.2.3.4:80?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject'))));
9898

9999
$this->connector->connect('google.com:80');
100100

@@ -104,7 +104,7 @@ public function testPassThroughResolverIfGivenHost()
104104
public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6()
105105
{
106106
$this->resolver->expects($this->exactly(2))->method('resolveAll')->with($this->equalTo('google.com'), $this->anything())->will($this->returnValue(Promise\resolve(array('::1'))));
107-
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('[::1]:80?hostname=google.com'))->will($this->returnValue(Promise\reject()));
107+
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('[::1]:80?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject'))));
108108

109109
$this->connector->connect('google.com:80');
110110

@@ -114,7 +114,7 @@ public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6()
114114
public function testPassByResolverIfGivenCompleteUri()
115115
{
116116
$this->resolver->expects($this->never())->method('resolveAll');
117-
$this->tcp->expects($this->once())->method('connect')->with($this->equalTo('scheme://127.0.0.1:80/path?query#fragment'))->will($this->returnValue(Promise\reject()));
117+
$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'))));
118118

119119
$this->connector->connect('scheme://127.0.0.1:80/path?query#fragment');
120120

@@ -124,7 +124,7 @@ public function testPassByResolverIfGivenCompleteUri()
124124
public function testPassThroughResolverIfGivenCompleteUri()
125125
{
126126
$this->resolver->expects($this->exactly(2))->method('resolveAll')->with($this->equalTo('google.com'), $this->anything())->will($this->returnValue(Promise\resolve(array('1.2.3.4'))));
127-
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('scheme://1.2.3.4:80/path?query&hostname=google.com#fragment'))->will($this->returnValue(Promise\reject()));
127+
$this->tcp->expects($this->exactly(2))->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'))));
128128

129129
$this->connector->connect('scheme://google.com:80/path?query#fragment');
130130

@@ -134,7 +134,7 @@ public function testPassThroughResolverIfGivenCompleteUri()
134134
public function testPassThroughResolverIfGivenExplicitHost()
135135
{
136136
$this->resolver->expects($this->exactly(2))->method('resolveAll')->with($this->equalTo('google.com'), $this->anything())->will($this->returnValue(Promise\resolve(array('1.2.3.4'))));
137-
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('scheme://1.2.3.4:80/?hostname=google.de'))->will($this->returnValue(Promise\reject()));
137+
$this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('scheme://1.2.3.4:80/?hostname=google.de'))->will($this->returnValue(Promise\reject(new \Exception('reject'))));
138138

139139
$this->connector->connect('scheme://google.com:80/?hostname=google.de');
140140

@@ -155,12 +155,12 @@ public function testIpv6ResolvesFirstSoIsTheFirstToConnect(array $ipv6, array $i
155155
$this->returnValue(Promise\resolve($ipv6)),
156156
$this->returnValue($deferred->promise())
157157
);
158-
$this->tcp->expects($this->any())->method('connect')->with($this->stringContains(']:80/?hostname=google.com'))->will($this->returnValue(Promise\reject()));
158+
$this->tcp->expects($this->any())->method('connect')->with($this->stringContains(']:80/?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject'))));
159159

160160
$this->connector->connect('scheme://google.com:80/?hostname=google.com');
161161

162162
$this->loop->addTimer(0.07, function () use ($deferred) {
163-
$deferred->reject(new \RuntimeException());
163+
$deferred->reject(new \Exception('reject'));
164164
});
165165

166166
$this->loop->run();
@@ -180,12 +180,12 @@ public function testIpv6DoesntResolvesWhileIpv4DoesFirstSoIpv4Connects(array $ip
180180
$this->returnValue($deferred->promise()),
181181
$this->returnValue(Promise\resolve($ipv4))
182182
);
183-
$this->tcp->expects($this->any())->method('connect')->with($this->stringContains(':80/?hostname=google.com'))->will($this->returnValue(Promise\reject()));
183+
$this->tcp->expects($this->any())->method('connect')->with($this->stringContains(':80/?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject'))));
184184

185185
$this->connector->connect('scheme://google.com:80/?hostname=google.com');
186186

187187
$this->loop->addTimer(0.07, function () use ($deferred) {
188-
$deferred->reject(new \RuntimeException());
188+
$deferred->reject(new \Exception('reject'));
189189
});
190190

191191
$this->loop->run();

0 commit comments

Comments
 (0)