| @@ 187-210 (lines=24) @@ | ||
| 184 | $this->assertEquals('https', $this->activeStack->getRequestScheme()); |
|
| 185 | } |
|
| 186 | ||
| 187 | public function testOnFulfilled(): void |
|
| 188 | { |
|
| 189 | $this->collector |
|
| 190 | ->expects($this->once()) |
|
| 191 | ->method('activateStack') |
|
| 192 | ->with($this->activeStack) |
|
| 193 | ; |
|
| 194 | ||
| 195 | $this->stopwatchEvent |
|
| 196 | ->expects($this->once()) |
|
| 197 | ->method('stop') |
|
| 198 | ; |
|
| 199 | ||
| 200 | $this->client |
|
| 201 | ->method('sendAsyncRequest') |
|
| 202 | ->willReturn($this->fulfilledPromise) |
|
| 203 | ; |
|
| 204 | ||
| 205 | $this->subject->sendAsyncRequest($this->request); |
|
| 206 | ||
| 207 | $this->assertEquals(42, $this->activeStack->getDuration()); |
|
| 208 | $this->assertEquals(200, $this->activeStack->getResponseCode()); |
|
| 209 | $this->assertEquals('FormattedResponse', $this->activeStack->getClientResponse()); |
|
| 210 | } |
|
| 211 | ||
| 212 | public function testOnRejected(): void |
|
| 213 | { |
|
| @@ 212-240 (lines=29) @@ | ||
| 209 | $this->assertEquals('FormattedResponse', $this->activeStack->getClientResponse()); |
|
| 210 | } |
|
| 211 | ||
| 212 | public function testOnRejected(): void |
|
| 213 | { |
|
| 214 | $this->collector |
|
| 215 | ->expects($this->once()) |
|
| 216 | ->method('activateStack') |
|
| 217 | ->with($this->activeStack) |
|
| 218 | ; |
|
| 219 | ||
| 220 | $this->stopwatchEvent |
|
| 221 | ->expects($this->once()) |
|
| 222 | ->method('stop') |
|
| 223 | ; |
|
| 224 | ||
| 225 | $this->client |
|
| 226 | ->method('sendAsyncRequest') |
|
| 227 | ->willReturn($this->rejectedPromise) |
|
| 228 | ; |
|
| 229 | ||
| 230 | $this->formatter |
|
| 231 | ->method('formatException') |
|
| 232 | ->with($this->exception) |
|
| 233 | ->willReturn('FormattedException') |
|
| 234 | ; |
|
| 235 | ||
| 236 | $this->subject->sendAsyncRequest($this->request); |
|
| 237 | ||
| 238 | $this->assertEquals(42, $this->activeStack->getDuration()); |
|
| 239 | $this->assertEquals('FormattedException', $this->activeStack->getClientException()); |
|
| 240 | } |
|
| 241 | } |
|
| 242 | ||
| 243 | interface ClientInterface extends HttpClient, HttpAsyncClient |
|