php-react-promise_2.5.1.orig.tar.gz
mirabilos authored 5 years ago
mirabilos committed 5 years ago
14 | 14 | - composer install |
15 | 15 | |
16 | 16 | script: |
17 | - phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml | |
17 | - ./vendor/bin/phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml | |
18 | 18 | |
19 | 19 | after_script: |
20 | 20 | - if [ -f ./build/logs/clover.xml ]; then travis_retry composer require satooshi/php-coveralls --no-interaction --update-with-dependencies; fi |
0 | CHANGELOG | |
1 | ========= | |
0 | CHANGELOG for 2.x | |
1 | ================= | |
2 | ||
3 | * 2.5.1 (2017-03-25) | |
4 | ||
5 | * Fix circular references when resolving with a promise which follows | |
6 | itself (#94). | |
7 | ||
8 | * 2.5.0 (2016-12-22) | |
9 | ||
10 | * Revert automatic cancellation of pending collection promises once the | |
11 | output promise resolves. This was introduced in 42d86b7 (PR #36, released | |
12 | in [v2.3.0](https://github.com/reactphp/promise/releases/tag/v2.3.0)) and | |
13 | was both unintended and backward incompatible. | |
14 | ||
15 | If you need automatic cancellation, you can use something like: | |
16 | ||
17 | ```php | |
18 | function allAndCancel(array $promises) | |
19 | { | |
20 | return \React\Promise\all($promises) | |
21 | ->always(function() use ($promises) { | |
22 | foreach ($promises as $promise) { | |
23 | if ($promise instanceof \React\Promise\CancellablePromiseInterface) { | |
24 | $promise->cancel(); | |
25 | } | |
26 | } | |
27 | }); | |
28 | } | |
29 | ``` | |
30 | * `all()` and `map()` functions now preserve the order of the array (#77). | |
31 | * Fix circular references when resolving a promise with itself (#71). | |
2 | 32 | |
3 | 33 | * 2.4.1 (2016-05-03) |
4 | 34 | |
63 | 93 | when initialized with a promise instead of a value/reason. |
64 | 94 | * BC break: `Deferred::resolve()` and `Deferred::reject()` no longer return |
65 | 95 | a promise. |
66 | ||
67 | * 1.0.4 (2013-04-03) | |
68 | ||
69 | * Trigger PHP errors when invalid callback is passed. | |
70 | * Fully resolve rejection value before calling rejection handler. | |
71 | * Add `When::lazy()` to create lazy promises which will be initialized once | |
72 | a consumer calls the `then()` method. | |
73 | ||
74 | * 1.0.3 (2012-11-17) | |
75 | ||
76 | * Add `PromisorInterface` for objects that have a `promise()` method. | |
77 | ||
78 | * 1.0.2 (2012-11-14) | |
79 | ||
80 | * Fix bug in `When::any()` not correctly unwrapping to a single result | |
81 | value. | |
82 | * `$promiseOrValue` argument of `When::resolve()` and When::reject() is now | |
83 | optional. | |
84 | ||
85 | * 1.0.1 (2012-11-13) | |
86 | ||
87 | * Prevent deep recursion which was reaching `xdebug.max_nesting_level` | |
88 | default of 100. | |
89 | ||
90 | * 1.0.0 (2012-11-07) | |
91 | ||
92 | * First tagged release. |
6 | 6 | ], |
7 | 7 | "require": { |
8 | 8 | "php": ">=5.4.0" |
9 | }, | |
10 | "require-dev": { | |
11 | "phpunit/phpunit": "~4.8" | |
9 | 12 | }, |
10 | 13 | "autoload": { |
11 | 14 | "psr-4": { |
18 | 21 | "React\\Promise\\": "tests/fixtures" |
19 | 22 | } |
20 | 23 | }, |
21 | "extra": { | |
22 | "branch-alias": { | |
23 | "dev-master": "2.0-dev" | |
24 | } | |
25 | } | |
24 | "keywords": [ | |
25 | "promise", | |
26 | "promises" | |
27 | ] | |
26 | 28 | } |
41 | 41 | return $this->promise()->cancel(); |
42 | 42 | } |
43 | 43 | |
44 | private function promise() | |
44 | /** | |
45 | * @internal | |
46 | * @see Promise::settle() | |
47 | */ | |
48 | public function promise() | |
45 | 49 | { |
46 | 50 | if (null === $this->promise) { |
47 | 51 | try { |
21 | 21 | public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) |
22 | 22 | { |
23 | 23 | if (null !== $this->result) { |
24 | return $this->result()->then($onFulfilled, $onRejected, $onProgress); | |
24 | return $this->result->then($onFulfilled, $onRejected, $onProgress); | |
25 | 25 | } |
26 | 26 | |
27 | 27 | if (null === $this->canceller) { |
42 | 42 | public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) |
43 | 43 | { |
44 | 44 | if (null !== $this->result) { |
45 | return $this->result()->done($onFulfilled, $onRejected, $onProgress); | |
45 | return $this->result->done($onFulfilled, $onRejected, $onProgress); | |
46 | 46 | } |
47 | 47 | |
48 | 48 | $this->handlers[] = function (ExtendedPromiseInterface $promise) use ($onFulfilled, $onRejected) { |
154 | 154 | |
155 | 155 | private function settle(ExtendedPromiseInterface $promise) |
156 | 156 | { |
157 | $promise = $this->unwrap($promise); | |
158 | ||
157 | 159 | $handlers = $this->handlers; |
158 | 160 | |
159 | 161 | $this->progressHandlers = $this->handlers = []; |
164 | 166 | } |
165 | 167 | } |
166 | 168 | |
167 | private function result() | |
168 | { | |
169 | while ($this->result instanceof self && null !== $this->result->result) { | |
170 | $this->result = $this->result->result; | |
171 | } | |
172 | ||
173 | return $this->result; | |
169 | private function unwrap($promise) | |
170 | { | |
171 | $promise = $this->extract($promise); | |
172 | ||
173 | while ($promise instanceof self && null !== $promise->result) { | |
174 | $promise = $this->extract($promise->result); | |
175 | } | |
176 | ||
177 | return $promise; | |
178 | } | |
179 | ||
180 | private function extract($promise) | |
181 | { | |
182 | if ($promise instanceof LazyPromise) { | |
183 | $promise = $promise->promise(); | |
184 | } | |
185 | ||
186 | if ($promise === $this) { | |
187 | return new RejectedPromise( | |
188 | new \LogicException('Cannot resolve a promise with itself.') | |
189 | ); | |
190 | } | |
191 | ||
192 | return $promise; | |
174 | 193 | } |
175 | 194 | |
176 | 195 | private function call(callable $callback) |
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | $fulfiller = function ($value) use ($cancellationQueue, $resolve) { | |
57 | $cancellationQueue(); | |
58 | $resolve($value); | |
59 | }; | |
60 | ||
61 | $rejecter = function ($reason) use ($cancellationQueue, $reject) { | |
62 | $cancellationQueue(); | |
63 | $reject($reason); | |
64 | }; | |
65 | ||
66 | 56 | foreach ($array as $promiseOrValue) { |
67 | 57 | $cancellationQueue->enqueue($promiseOrValue); |
68 | 58 | |
69 | 59 | resolve($promiseOrValue) |
70 | ->done($fulfiller, $rejecter, $notify); | |
60 | ->done($resolve, $reject, $notify); | |
71 | 61 | } |
72 | 62 | }, $reject, $notify); |
73 | 63 | }, $cancellationQueue); |
114 | 104 | $reasons = []; |
115 | 105 | |
116 | 106 | foreach ($array as $i => $promiseOrValue) { |
117 | $fulfiller = function ($val) use ($i, &$values, &$toResolve, $toReject, $resolve, $cancellationQueue) { | |
107 | $fulfiller = function ($val) use ($i, &$values, &$toResolve, $toReject, $resolve) { | |
118 | 108 | if ($toResolve < 1 || $toReject < 1) { |
119 | 109 | return; |
120 | 110 | } |
122 | 112 | $values[$i] = $val; |
123 | 113 | |
124 | 114 | if (0 === --$toResolve) { |
125 | $cancellationQueue(); | |
126 | 115 | $resolve($values); |
127 | 116 | } |
128 | 117 | }; |
129 | 118 | |
130 | $rejecter = function ($reason) use ($i, &$reasons, &$toReject, $toResolve, $reject, $cancellationQueue) { | |
119 | $rejecter = function ($reason) use ($i, &$reasons, &$toReject, $toResolve, $reject) { | |
131 | 120 | if ($toResolve < 1 || $toReject < 1) { |
132 | 121 | return; |
133 | 122 | } |
135 | 124 | $reasons[$i] = $reason; |
136 | 125 | |
137 | 126 | if (0 === --$toReject) { |
138 | $cancellationQueue(); | |
139 | 127 | $reject($reasons); |
140 | 128 | } |
141 | 129 | }; |
167 | 155 | |
168 | 156 | foreach ($array as $i => $promiseOrValue) { |
169 | 157 | $cancellationQueue->enqueue($promiseOrValue); |
158 | $values[$i] = null; | |
170 | 159 | |
171 | 160 | resolve($promiseOrValue) |
172 | 161 | ->then($mapFunc) |
73 | 73 | { |
74 | 74 | $this->setExpectedException('\Exception', 'test'); |
75 | 75 | |
76 | $mock = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
76 | $mock = $this | |
77 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
78 | ->getMock(); | |
77 | 79 | $mock |
78 | 80 | ->expects($this->once()) |
79 | 81 | ->method('cancel') |
93 | 93 | all(resolve(1)) |
94 | 94 | ->then($mock); |
95 | 95 | } |
96 | ||
97 | /** @test */ | |
98 | public function shouldPreserveTheOrderOfArrayWhenResolvingAsyncPromises() | |
99 | { | |
100 | $mock = $this->createCallableMock(); | |
101 | $mock | |
102 | ->expects($this->once()) | |
103 | ->method('__invoke') | |
104 | ->with($this->identicalTo([1, 2, 3])); | |
105 | ||
106 | $deferred = new Deferred(); | |
107 | ||
108 | all([resolve(1), $deferred->promise(), resolve(3)]) | |
109 | ->then($mock); | |
110 | ||
111 | $deferred->resolve(2); | |
112 | } | |
96 | 113 | } |
149 | 149 | /** @test */ |
150 | 150 | public function shouldCancelInputPromise() |
151 | 151 | { |
152 | $mock = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
152 | $mock = $this | |
153 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
154 | ->getMock(); | |
153 | 155 | $mock |
154 | 156 | ->expects($this->once()) |
155 | 157 | ->method('cancel'); |
160 | 162 | /** @test */ |
161 | 163 | public function shouldCancelInputArrayPromises() |
162 | 164 | { |
163 | $mock1 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
165 | $mock1 = $this | |
166 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
167 | ->getMock(); | |
164 | 168 | $mock1 |
165 | 169 | ->expects($this->once()) |
166 | 170 | ->method('cancel'); |
167 | 171 | |
168 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
172 | $mock2 = $this | |
173 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
174 | ->getMock(); | |
169 | 175 | $mock2 |
170 | 176 | ->expects($this->once()) |
171 | 177 | ->method('cancel'); |
174 | 180 | } |
175 | 181 | |
176 | 182 | /** @test */ |
177 | public function shouldCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills() | |
183 | public function shouldNotCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills() | |
178 | 184 | { |
179 | 185 | $mock = $this->createCallableMock(); |
180 | 186 | $mock |
185 | 191 | $deferred = New Deferred($mock); |
186 | 192 | $deferred->resolve(); |
187 | 193 | |
188 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
194 | $mock2 = $this | |
195 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
196 | ->getMock(); | |
189 | 197 | $mock2 |
190 | ->expects($this->once()) | |
198 | ->expects($this->never()) | |
191 | 199 | ->method('cancel'); |
192 | 200 | |
193 | 201 | some([$deferred->promise(), $mock2], 1)->cancel(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | /** @test */ |
111 | public function shouldPreserveTheOrderOfArrayWhenResolvingAsyncPromises() | |
112 | { | |
113 | $mock = $this->createCallableMock(); | |
114 | $mock | |
115 | ->expects($this->once()) | |
116 | ->method('__invoke') | |
117 | ->with($this->identicalTo([2, 4, 6])); | |
118 | ||
119 | $deferred = new Deferred(); | |
120 | ||
121 | map( | |
122 | [resolve(1), $deferred->promise(), resolve(3)], | |
123 | $this->mapper() | |
124 | )->then($mock); | |
125 | ||
126 | $deferred->resolve(2); | |
127 | } | |
128 | ||
129 | /** @test */ | |
111 | 130 | public function shouldRejectWhenInputContainsRejection() |
112 | 131 | { |
113 | 132 | $mock = $this->createCallableMock(); |
140 | 159 | /** @test */ |
141 | 160 | public function shouldCancelInputPromise() |
142 | 161 | { |
143 | $mock = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
162 | $mock = $this | |
163 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
164 | ->getMock(); | |
144 | 165 | $mock |
145 | 166 | ->expects($this->once()) |
146 | 167 | ->method('cancel'); |
154 | 175 | /** @test */ |
155 | 176 | public function shouldCancelInputArrayPromises() |
156 | 177 | { |
157 | $mock1 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
178 | $mock1 = $this | |
179 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
180 | ->getMock(); | |
158 | 181 | $mock1 |
159 | 182 | ->expects($this->once()) |
160 | 183 | ->method('cancel'); |
161 | 184 | |
162 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
185 | $mock2 = $this | |
186 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
187 | ->getMock(); | |
163 | 188 | $mock2 |
164 | 189 | ->expects($this->once()) |
165 | 190 | ->method('cancel'); |
136 | 136 | /** @test */ |
137 | 137 | public function shouldCancelInputPromise() |
138 | 138 | { |
139 | $mock = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
139 | $mock = $this | |
140 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
141 | ->getMock(); | |
140 | 142 | $mock |
141 | 143 | ->expects($this->once()) |
142 | 144 | ->method('cancel'); |
147 | 149 | /** @test */ |
148 | 150 | public function shouldCancelInputArrayPromises() |
149 | 151 | { |
150 | $mock1 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
152 | $mock1 = $this | |
153 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
154 | ->getMock(); | |
151 | 155 | $mock1 |
152 | 156 | ->expects($this->once()) |
153 | 157 | ->method('cancel'); |
154 | 158 | |
155 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
159 | $mock2 = $this | |
160 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
161 | ->getMock(); | |
156 | 162 | $mock2 |
157 | 163 | ->expects($this->once()) |
158 | 164 | ->method('cancel'); |
161 | 167 | } |
162 | 168 | |
163 | 169 | /** @test */ |
164 | public function shouldCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills() | |
170 | public function shouldNotCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills() | |
165 | 171 | { |
166 | 172 | $mock = $this->createCallableMock(); |
167 | 173 | $mock |
171 | 177 | $deferred = New Deferred($mock); |
172 | 178 | $deferred->resolve(); |
173 | 179 | |
174 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
180 | $mock2 = $this | |
181 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
182 | ->getMock(); | |
175 | 183 | $mock2 |
176 | ->expects($this->once()) | |
184 | ->expects($this->never()) | |
177 | 185 | ->method('cancel'); |
178 | 186 | |
179 | 187 | race([$deferred->promise(), $mock2])->cancel(); |
180 | 188 | } |
181 | 189 | |
182 | 190 | /** @test */ |
183 | public function shouldCancelOtherPendingInputArrayPromisesIfOnePromiseRejects() | |
191 | public function shouldNotCancelOtherPendingInputArrayPromisesIfOnePromiseRejects() | |
184 | 192 | { |
185 | 193 | $mock = $this->createCallableMock(); |
186 | 194 | $mock |
190 | 198 | $deferred = New Deferred($mock); |
191 | 199 | $deferred->reject(); |
192 | 200 | |
193 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
201 | $mock2 = $this | |
202 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
203 | ->getMock(); | |
194 | 204 | $mock2 |
195 | ->expects($this->once()) | |
205 | ->expects($this->never()) | |
196 | 206 | ->method('cancel'); |
197 | 207 | |
198 | 208 | race([$deferred->promise(), $mock2])->cancel(); |
306 | 306 | /** @test */ |
307 | 307 | public function shouldCancelInputPromise() |
308 | 308 | { |
309 | $mock = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
309 | $mock = $this | |
310 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
311 | ->getMock(); | |
310 | 312 | $mock |
311 | 313 | ->expects($this->once()) |
312 | 314 | ->method('cancel'); |
321 | 323 | /** @test */ |
322 | 324 | public function shouldCancelInputArrayPromises() |
323 | 325 | { |
324 | $mock1 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
326 | $mock1 = $this | |
327 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
328 | ->getMock(); | |
325 | 329 | $mock1 |
326 | 330 | ->expects($this->once()) |
327 | 331 | ->method('cancel'); |
328 | 332 | |
329 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
333 | $mock2 = $this | |
334 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
335 | ->getMock(); | |
330 | 336 | $mock2 |
331 | 337 | ->expects($this->once()) |
332 | 338 | ->method('cancel'); |
161 | 161 | /** @test */ |
162 | 162 | public function returnsExtendePromiseForSimplePromise() |
163 | 163 | { |
164 | $promise = $this->getMock('React\Promise\PromiseInterface'); | |
164 | $promise = $this | |
165 | ->getMockBuilder('React\Promise\PromiseInterface') | |
166 | ->getMock(); | |
165 | 167 | |
166 | 168 | $this->assertInstanceOf('React\Promise\ExtendedPromiseInterface', resolve($promise)); |
167 | 169 | } |
183 | 183 | /** @test */ |
184 | 184 | public function shouldCancelInputPromise() |
185 | 185 | { |
186 | $mock = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
186 | $mock = $this | |
187 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
188 | ->getMock(); | |
187 | 189 | $mock |
188 | 190 | ->expects($this->once()) |
189 | 191 | ->method('cancel'); |
194 | 196 | /** @test */ |
195 | 197 | public function shouldCancelInputArrayPromises() |
196 | 198 | { |
197 | $mock1 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
199 | $mock1 = $this | |
200 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
201 | ->getMock(); | |
198 | 202 | $mock1 |
199 | 203 | ->expects($this->once()) |
200 | 204 | ->method('cancel'); |
201 | 205 | |
202 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
206 | $mock2 = $this | |
207 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
208 | ->getMock(); | |
203 | 209 | $mock2 |
204 | 210 | ->expects($this->once()) |
205 | 211 | ->method('cancel'); |
208 | 214 | } |
209 | 215 | |
210 | 216 | /** @test */ |
211 | public function shouldCancelOtherPendingInputArrayPromisesIfEnoughPromisesFulfill() | |
217 | public function shouldNotCancelOtherPendingInputArrayPromisesIfEnoughPromisesFulfill() | |
212 | 218 | { |
213 | 219 | $mock = $this->createCallableMock(); |
214 | 220 | $mock |
218 | 224 | $deferred = New Deferred($mock); |
219 | 225 | $deferred->resolve(); |
220 | 226 | |
221 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
227 | $mock2 = $this | |
228 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
229 | ->getMock(); | |
222 | 230 | $mock2 |
223 | ->expects($this->once()) | |
231 | ->expects($this->never()) | |
224 | 232 | ->method('cancel'); |
225 | 233 | |
226 | 234 | some([$deferred->promise(), $mock2], 1); |
227 | 235 | } |
228 | 236 | |
229 | 237 | /** @test */ |
230 | public function shouldCancelOtherPendingInputArrayPromisesIfEnoughPromisesReject() | |
238 | public function shouldNotCancelOtherPendingInputArrayPromisesIfEnoughPromisesReject() | |
231 | 239 | { |
232 | 240 | $mock = $this->createCallableMock(); |
233 | 241 | $mock |
237 | 245 | $deferred = New Deferred($mock); |
238 | 246 | $deferred->reject(); |
239 | 247 | |
240 | $mock2 = $this->getMock('React\Promise\CancellablePromiseInterface'); | |
248 | $mock2 = $this | |
249 | ->getMockBuilder('React\Promise\CancellablePromiseInterface') | |
250 | ->getMock(); | |
241 | 251 | $mock2 |
242 | ->expects($this->once()) | |
252 | ->expects($this->never()) | |
243 | 253 | ->method('cancel'); |
244 | 254 | |
245 | 255 | some([$deferred->promise(), $mock2], 2); |
111 | 111 | $adapter->resolve(2); |
112 | 112 | } |
113 | 113 | |
114 | /** | |
115 | * @test | |
116 | */ | |
117 | public function resolveShouldRejectWhenResolvedWithItself() | |
118 | { | |
119 | $adapter = $this->getPromiseTestAdapter(); | |
120 | ||
121 | $mock = $this->createCallableMock(); | |
122 | $mock | |
123 | ->expects($this->once()) | |
124 | ->method('__invoke') | |
125 | ->with(new \LogicException('Cannot resolve a promise with itself.')); | |
126 | ||
127 | $adapter->promise() | |
128 | ->then( | |
129 | $this->expectCallableNever(), | |
130 | $mock | |
131 | ); | |
132 | ||
133 | $adapter->resolve($adapter->promise()); | |
134 | } | |
135 | ||
136 | /** | |
137 | * @test | |
138 | */ | |
139 | public function resolveShouldRejectWhenResolvedWithAPromiseWhichFollowsItself() | |
140 | { | |
141 | $adapter1 = $this->getPromiseTestAdapter(); | |
142 | $adapter2 = $this->getPromiseTestAdapter(); | |
143 | ||
144 | $mock = $this->createCallableMock(); | |
145 | $mock | |
146 | ->expects($this->once()) | |
147 | ->method('__invoke') | |
148 | ->with(new \LogicException('Cannot resolve a promise with itself.')); | |
149 | ||
150 | $promise1 = $adapter1->promise(); | |
151 | ||
152 | $promise2 = $adapter2->promise(); | |
153 | ||
154 | $promise2->then( | |
155 | $this->expectCallableNever(), | |
156 | $mock | |
157 | ); | |
158 | ||
159 | $adapter1->resolve($promise2); | |
160 | $adapter2->resolve($promise1); | |
161 | } | |
162 | ||
114 | 163 | /** @test */ |
115 | 164 | public function doneShouldInvokeFulfillmentHandler() |
116 | 165 | { |