PluginProbe
WP-Stateless – Google Cloud Storage / 2.1.4
WP-Stateless – Google Cloud Storage v2.1.4
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / Google / vendor / react / promise / tests / FulfilledPromiseTest.php

FulfilledPromiseTest.php in WP-Stateless – Google Cloud Storage 2.1.4, at lib/Google/vendor/react/promise/tests/FulfilledPromiseTest.php

51 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace React\Promise;
4
5 use React\Promise\PromiseAdapter\CallbackPromiseAdapter;
6
7 class FulfilledPromiseTest extends TestCase
8 {
9 use PromiseTest\PromiseSettledTestTrait,
10 PromiseTest\PromiseFulfilledTestTrait;
11
12 public function getPromiseTestAdapter(callable $canceller = null)
13 {
14 $promise = null;
15
16 return new CallbackPromiseAdapter([
17 'promise' => function () use (&$promise) {
18 if (!$promise) {
19 throw new \LogicException('FulfilledPromise must be resolved before obtaining the promise');
20 }
21
22 return $promise;
23 },
24 'resolve' => function ($value = null) use (&$promise) {
25 if (!$promise) {
26 $promise = new FulfilledPromise($value);
27 }
28 },
29 'reject' => function () {
30 throw new \LogicException('You cannot call reject() for React\Promise\FulfilledPromise');
31 },
32 'notify' => function () {
33 // no-op
34 },
35 'settle' => function ($value = null) use (&$promise) {
36 if (!$promise) {
37 $promise = new FulfilledPromise($value);
38 }
39 },
40 ]);
41 }
42
43 /** @test */
44 public function shouldThrowExceptionIfConstructedWithAPromise()
45 {
46 $this->setExpectedException('\InvalidArgumentException');
47
48 return new FulfilledPromise(new FulfilledPromise());
49 }
50 }
51