Skip to content

Commit 3a74f3c

Browse files
committed
make async call consistent with promise interface
1 parent 145edcf commit 3a74f3c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/HttpAsyncClientTest.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ public function testSuccessiveCallMustUseResponseInterface()
4646
$response = null;
4747
$promise->then()->then()->then(function ($r) use(&$response) {
4848
$response = $r;
49+
50+
return $response;
4951
});
5052

51-
$promise->wait();
53+
$promise->wait(false);
5254
$this->assertResponse(
5355
$response,
5456
[
@@ -72,11 +74,15 @@ public function testSuccessiveInvalidCallMustUseException()
7274
$response = null;
7375
$promise->then()->then()->then(function ($r) use(&$response) {
7476
$response = $r;
77+
78+
return $response;
7579
}, function ($e) use (&$exception) {
7680
$exception = $e;
81+
82+
throw $e;
7783
});
7884

79-
$promise->wait();
85+
$promise->wait(false);
8086

8187
$this->assertNull($response);
8288
$this->assertNotNull($exception);
@@ -106,6 +112,8 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body)
106112
$response = null;
107113
$promise->then(function ($r) use(&$response) {
108114
$response = $r;
115+
116+
return $response;
109117
});
110118

111119
$promise->wait();
@@ -136,10 +144,14 @@ public function testSendAsyncWithInvalidUri()
136144

137145
$promise->then(function ($r) use(&$response) {
138146
$response = $r;
147+
148+
return $response;
139149
}, function ($e) use (&$exception) {
140150
$exception = $e;
151+
152+
throw $e;
141153
});
142-
$promise->wait();
154+
$promise->wait(false);
143155

144156
$this->assertNull($response);
145157
$this->assertNotNull($exception);
@@ -175,6 +187,8 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion
175187
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
176188
$promise->then(function ($r) use(&$response) {
177189
$response = $r;
190+
191+
return $response;
178192
});
179193

180194
$this->assertInstanceOf('Http\Promise\Promise', $promise);

0 commit comments

Comments
 (0)