diff --git a/composer.json b/composer.json index 5a43ed92..2accad6c 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "evenement/evenement": "^3.0 || ^2.0 || ^1.0", "react/dns": "^1.1", "react/event-loop": "^1.0 || ^0.5", - "react/promise": "^2.6.0 || ^1.2.1", + "react/promise": "dev-master as 2.999.9999", "react/promise-timer": "^1.4.0", "react/stream": "^1.1" }, diff --git a/tests/DnsConnectorTest.php b/tests/DnsConnectorTest.php index f6401931..d5dd6920 100644 --- a/tests/DnsConnectorTest.php +++ b/tests/DnsConnectorTest.php @@ -26,7 +26,7 @@ public function setUpMocks() public function testPassByResolverIfGivenIp() { $this->resolver->expects($this->never())->method('resolve'); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('127.0.0.1:80'))->will($this->returnValue(Promise\reject())); + $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('127.0.0.1:80'))->will($this->returnValue(Promise\reject(new \Exception('reject')))); $this->connector->connect('127.0.0.1:80'); } @@ -34,7 +34,7 @@ public function testPassByResolverIfGivenIp() public function testPassThroughResolverIfGivenHost() { $this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('google.com'))->will($this->returnValue(Promise\resolve('1.2.3.4'))); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('1.2.3.4:80?hostname=google.com'))->will($this->returnValue(Promise\reject())); + $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')))); $this->connector->connect('google.com:80'); } @@ -42,7 +42,7 @@ public function testPassThroughResolverIfGivenHost() public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6() { $this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('google.com'))->will($this->returnValue(Promise\resolve('::1'))); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('[::1]:80?hostname=google.com'))->will($this->returnValue(Promise\reject())); + $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('[::1]:80?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject')))); $this->connector->connect('google.com:80'); } @@ -50,7 +50,7 @@ public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6() public function testPassByResolverIfGivenCompleteUri() { $this->resolver->expects($this->never())->method('resolve'); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('scheme://127.0.0.1:80/path?query#fragment'))->will($this->returnValue(Promise\reject())); + $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')))); $this->connector->connect('scheme://127.0.0.1:80/path?query#fragment'); } @@ -58,7 +58,7 @@ public function testPassByResolverIfGivenCompleteUri() public function testPassThroughResolverIfGivenCompleteUri() { $this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('google.com'))->will($this->returnValue(Promise\resolve('1.2.3.4'))); - $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())); + $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')))); $this->connector->connect('scheme://google.com:80/path?query#fragment'); } @@ -66,7 +66,7 @@ public function testPassThroughResolverIfGivenCompleteUri() public function testPassThroughResolverIfGivenExplicitHost() { $this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('google.com'))->will($this->returnValue(Promise\resolve('1.2.3.4'))); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('scheme://1.2.3.4:80/?hostname=google.de'))->will($this->returnValue(Promise\reject())); + $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')))); $this->connector->connect('scheme://google.com:80/?hostname=google.de'); } diff --git a/tests/HappyEyeBallsConnectorTest.php b/tests/HappyEyeBallsConnectorTest.php index 6af7807a..710efeb4 100644 --- a/tests/HappyEyeBallsConnectorTest.php +++ b/tests/HappyEyeBallsConnectorTest.php @@ -84,7 +84,7 @@ public function testPassByResolverIfGivenIp() public function testPassByResolverIfGivenIpv6() { $this->resolver->expects($this->never())->method('resolveAll'); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('[::1]:80'))->will($this->returnValue(Promise\reject())); + $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('[::1]:80'))->will($this->returnValue(Promise\reject(new \Exception('reject')))); $this->connector->connect('[::1]:80'); @@ -94,7 +94,7 @@ public function testPassByResolverIfGivenIpv6() public function testPassThroughResolverIfGivenHost() { $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')))); - $this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('1.2.3.4:80?hostname=google.com'))->will($this->returnValue(Promise\reject())); + $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')))); $this->connector->connect('google.com:80'); @@ -104,7 +104,7 @@ public function testPassThroughResolverIfGivenHost() public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6() { $this->resolver->expects($this->exactly(2))->method('resolveAll')->with($this->equalTo('google.com'), $this->anything())->will($this->returnValue(Promise\resolve(array('::1')))); - $this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('[::1]:80?hostname=google.com'))->will($this->returnValue(Promise\reject())); + $this->tcp->expects($this->exactly(2))->method('connect')->with($this->equalTo('[::1]:80?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject')))); $this->connector->connect('google.com:80'); @@ -114,7 +114,7 @@ public function testPassThroughResolverIfGivenHostWhichResolvesToIpv6() public function testPassByResolverIfGivenCompleteUri() { $this->resolver->expects($this->never())->method('resolveAll'); - $this->tcp->expects($this->once())->method('connect')->with($this->equalTo('scheme://127.0.0.1:80/path?query#fragment'))->will($this->returnValue(Promise\reject())); + $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')))); $this->connector->connect('scheme://127.0.0.1:80/path?query#fragment'); @@ -124,7 +124,7 @@ public function testPassByResolverIfGivenCompleteUri() public function testPassThroughResolverIfGivenCompleteUri() { $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')))); - $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())); + $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')))); $this->connector->connect('scheme://google.com:80/path?query#fragment'); @@ -134,7 +134,7 @@ public function testPassThroughResolverIfGivenCompleteUri() public function testPassThroughResolverIfGivenExplicitHost() { $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')))); - $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())); + $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')))); $this->connector->connect('scheme://google.com:80/?hostname=google.de'); @@ -155,12 +155,12 @@ public function testIpv6ResolvesFirstSoIsTheFirstToConnect(array $ipv6, array $i $this->returnValue(Promise\resolve($ipv6)), $this->returnValue($deferred->promise()) ); - $this->tcp->expects($this->any())->method('connect')->with($this->stringContains(']:80/?hostname=google.com'))->will($this->returnValue(Promise\reject())); + $this->tcp->expects($this->any())->method('connect')->with($this->stringContains(']:80/?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject')))); $this->connector->connect('scheme://google.com:80/?hostname=google.com'); $this->loop->addTimer(0.07, function () use ($deferred) { - $deferred->reject(new \RuntimeException()); + $deferred->reject(new \Exception('reject')); }); $this->loop->run(); @@ -180,12 +180,12 @@ public function testIpv6DoesntResolvesWhileIpv4DoesFirstSoIpv4Connects(array $ip $this->returnValue($deferred->promise()), $this->returnValue(Promise\resolve($ipv4)) ); - $this->tcp->expects($this->any())->method('connect')->with($this->stringContains(':80/?hostname=google.com'))->will($this->returnValue(Promise\reject())); + $this->tcp->expects($this->any())->method('connect')->with($this->stringContains(':80/?hostname=google.com'))->will($this->returnValue(Promise\reject(new \Exception('reject')))); $this->connector->connect('scheme://google.com:80/?hostname=google.com'); $this->loop->addTimer(0.07, function () use ($deferred) { - $deferred->reject(new \RuntimeException()); + $deferred->reject(new \Exception('reject')); }); $this->loop->run();