Skip to content

Commit 48e5c0e

Browse files
committed
Merge pull request #13 from php-http/feature/promise-update
Update library with upcoming change to promise
2 parents 7c68190 + 3a74f3c commit 48e5c0e

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/HttpAsyncClientTest.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ public function testSuccessiveCallMustUseResponseInterface()
4141
);
4242

4343
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
44-
$this->assertInstanceOf('Http\Client\Promise', $promise);
44+
$this->assertInstanceOf('Http\Promise\Promise', $promise);
4545

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
[
@@ -66,17 +68,21 @@ public function testSuccessiveInvalidCallMustUseException()
6668
);
6769

6870
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
69-
$this->assertInstanceOf('Http\Client\Promise', $promise);
71+
$this->assertInstanceOf('Http\Promise\Promise', $promise);
7072

7173
$exception = null;
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);
@@ -101,11 +107,13 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body)
101107
);
102108

103109
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
104-
$this->assertInstanceOf('Http\Client\Promise', $promise);
110+
$this->assertInstanceOf('Http\Promise\Promise', $promise);
105111

106112
$response = null;
107113
$promise->then(function ($r) use(&$response) {
108114
$response = $r;
115+
116+
return $response;
109117
});
110118

111119
$promise->wait();
@@ -132,14 +140,18 @@ public function testSendAsyncWithInvalidUri()
132140
$exception = null;
133141
$response = null;
134142
$promise = $this->httpAsyncClient->sendAsyncRequest($request);
135-
$this->assertInstanceOf('Http\Client\Promise', $promise);
143+
$this->assertInstanceOf('Http\Promise\Promise', $promise);
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,9 +187,11 @@ 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

180-
$this->assertInstanceOf('Http\Client\Promise', $promise);
194+
$this->assertInstanceOf('Http\Promise\Promise', $promise);
181195
$promise->wait();
182196
$this->assertResponse(
183197
$response,
@@ -186,4 +200,3 @@ public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion
186200
$this->assertRequest($method, $headers, $body, $protocolVersion);
187201
}
188202
}
189-

0 commit comments

Comments
 (0)