| @@ 276-302 (lines=27) @@ | ||
| 273 | ->variable($null) |
|
| 274 | ->isNull(); |
|
| 275 | ||
| 276 | if ($promise->state()->equals(State::FULFILLED())) { |
|
| 277 | $this |
|
| 278 | ->given( |
|
| 279 | $onFulfilled = $this->delegateMock(), |
|
| 280 | $onRejected = $this->delegateMock(), |
|
| 281 | $onNotify = $this->delegateMock(), |
|
| 282 | $value = $this->defaultResolveValue() |
|
| 283 | ) |
|
| 284 | ->when($promise->done($onFulfilled, $onRejected, $onNotify)) |
|
| 285 | ->then() |
|
| 286 | ->delegateCall($onFulfilled) |
|
| 287 | ->withArguments($value) |
|
| 288 | ->once() |
|
| 289 | ->delegateCall($onRejected) |
|
| 290 | ->never() |
|
| 291 | ->delegateCall($onNotify) |
|
| 292 | ->never(); |
|
| 293 | ||
| 294 | $this |
|
| 295 | ->given( |
|
| 296 | $onFulfilled = $this->delegateMockWithException(new \Exception()) |
|
| 297 | ) |
|
| 298 | ->exception(function () use ($promise, $onFulfilled) { |
|
| 299 | $promise->done($onFulfilled); |
|
| 300 | })->isInstanceof(\Exception::class) |
|
| 301 | ; |
|
| 302 | } |
|
| 303 | ||
| 304 | if ($promise->state()->equals(State::REJECTED())) { |
|
| 305 | $this |
|
| @@ 304-331 (lines=28) @@ | ||
| 301 | ; |
|
| 302 | } |
|
| 303 | ||
| 304 | if ($promise->state()->equals(State::REJECTED())) { |
|
| 305 | $this |
|
| 306 | ->given( |
|
| 307 | $onFulfilled = $this->delegateMock(), |
|
| 308 | $onRejected = $this->delegateMock(), |
|
| 309 | $onNotify = $this->delegateMock(), |
|
| 310 | $reason = $this->defaultRejectReason() |
|
| 311 | ) |
|
| 312 | ->when($promise->done($onFulfilled, $onRejected, $onNotify)) |
|
| 313 | ->then() |
|
| 314 | ->delegateCall($onFulfilled) |
|
| 315 | ->never() |
|
| 316 | ->delegateCall($onRejected) |
|
| 317 | ->withArguments($reason) |
|
| 318 | ->once() |
|
| 319 | ->delegateCall($onNotify) |
|
| 320 | ->never() |
|
| 321 | ; |
|
| 322 | ||
| 323 | $this |
|
| 324 | ->given( |
|
| 325 | $onRejected = $this->delegateMockWithException(new \Exception()) |
|
| 326 | ) |
|
| 327 | ->exception(function () use ($promise, $onRejected) { |
|
| 328 | $promise->done(null, $onRejected); |
|
| 329 | })->isInstanceof(\Exception::class) |
|
| 330 | ; |
|
| 331 | } |
|
| 332 | } |
|
| 333 | ||
| 334 | /** |
|