From 145edcff92ab85fbfc91af09add9aec57a2e4d7d Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Sun, 13 Dec 2015 01:39:03 +0100 Subject: [PATCH 1/2] Update library with upcoming change to promise --- src/HttpAsyncClientTest.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/HttpAsyncClientTest.php b/src/HttpAsyncClientTest.php index 2daa27f..a23824f 100644 --- a/src/HttpAsyncClientTest.php +++ b/src/HttpAsyncClientTest.php @@ -41,7 +41,7 @@ public function testSuccessiveCallMustUseResponseInterface() ); $promise = $this->httpAsyncClient->sendAsyncRequest($request); - $this->assertInstanceOf('Http\Client\Promise', $promise); + $this->assertInstanceOf('Http\Promise\Promise', $promise); $response = null; $promise->then()->then()->then(function ($r) use(&$response) { @@ -66,7 +66,7 @@ public function testSuccessiveInvalidCallMustUseException() ); $promise = $this->httpAsyncClient->sendAsyncRequest($request); - $this->assertInstanceOf('Http\Client\Promise', $promise); + $this->assertInstanceOf('Http\Promise\Promise', $promise); $exception = null; $response = null; @@ -101,7 +101,7 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body) ); $promise = $this->httpAsyncClient->sendAsyncRequest($request); - $this->assertInstanceOf('Http\Client\Promise', $promise); + $this->assertInstanceOf('Http\Promise\Promise', $promise); $response = null; $promise->then(function ($r) use(&$response) { @@ -132,7 +132,7 @@ public function testSendAsyncWithInvalidUri() $exception = null; $response = null; $promise = $this->httpAsyncClient->sendAsyncRequest($request); - $this->assertInstanceOf('Http\Client\Promise', $promise); + $this->assertInstanceOf('Http\Promise\Promise', $promise); $promise->then(function ($r) use(&$response) { $response = $r; @@ -177,7 +177,7 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion $response = $r; }); - $this->assertInstanceOf('Http\Client\Promise', $promise); + $this->assertInstanceOf('Http\Promise\Promise', $promise); $promise->wait(); $this->assertResponse( $response, @@ -186,4 +186,3 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion $this->assertRequest($method, $headers, $body, $protocolVersion); } } - \ No newline at end of file From 3a74f3c66a21a27dc2756622a68ff2bd4594dd8b Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Sun, 13 Dec 2015 02:20:39 +0100 Subject: [PATCH 2/2] make async call consistent with promise interface --- src/HttpAsyncClientTest.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/HttpAsyncClientTest.php b/src/HttpAsyncClientTest.php index a23824f..ceedb91 100644 --- a/src/HttpAsyncClientTest.php +++ b/src/HttpAsyncClientTest.php @@ -46,9 +46,11 @@ public function testSuccessiveCallMustUseResponseInterface() $response = null; $promise->then()->then()->then(function ($r) use(&$response) { $response = $r; + + return $response; }); - $promise->wait(); + $promise->wait(false); $this->assertResponse( $response, [ @@ -72,11 +74,15 @@ public function testSuccessiveInvalidCallMustUseException() $response = null; $promise->then()->then()->then(function ($r) use(&$response) { $response = $r; + + return $response; }, function ($e) use (&$exception) { $exception = $e; + + throw $e; }); - $promise->wait(); + $promise->wait(false); $this->assertNull($response); $this->assertNotNull($exception); @@ -106,6 +112,8 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body) $response = null; $promise->then(function ($r) use(&$response) { $response = $r; + + return $response; }); $promise->wait(); @@ -136,10 +144,14 @@ public function testSendAsyncWithInvalidUri() $promise->then(function ($r) use(&$response) { $response = $r; + + return $response; }, function ($e) use (&$exception) { $exception = $e; + + throw $e; }); - $promise->wait(); + $promise->wait(false); $this->assertNull($response); $this->assertNotNull($exception); @@ -175,6 +187,8 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion $promise = $this->httpAsyncClient->sendAsyncRequest($request); $promise->then(function ($r) use(&$response) { $response = $r; + + return $response; }); $this->assertInstanceOf('Http\Promise\Promise', $promise);