File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,10 @@ public function cancel()
9191 return ;
9292 }
9393
94- $ this ->call ($ this ->canceller );
94+ $ canceller = $ this ->canceller ;
95+ $ this ->canceller = null ;
96+
97+ $ this ->call ($ canceller );
9598 }
9699
97100 private function resolver (callable $ onFulfilled = null , callable $ onRejected = null , callable $ onProgress = null )
Original file line number Diff line number Diff line change @@ -189,6 +189,31 @@ public function cancelShouldTriggerCancellerWhenAllChildrenCancel()
189189 $ child2 ->cancel ();
190190 }
191191
192+ /** @test */
193+ public function cancelShouldNotTriggerCancellerWhenCancellingOneChildrenMultipleTimes ()
194+ {
195+ $ adapter = $ this ->getPromiseTestAdapter ($ this ->expectCallableNever ());
196+
197+ $ child1 = $ adapter ->promise ()
198+ ->then ()
199+ ->then ();
200+
201+ $ child2 = $ adapter ->promise ()
202+ ->then ();
203+
204+ $ child1 ->cancel ();
205+ $ child1 ->cancel ();
206+ }
207+
208+ /** @test */
209+ public function cancelShouldTriggerCancellerOnlyOnceWhenCancellingMultipleTimes ()
210+ {
211+ $ adapter = $ this ->getPromiseTestAdapter ($ this ->expectCallableOnce ());
212+
213+ $ adapter ->promise ()->cancel ();
214+ $ adapter ->promise ()->cancel ();
215+ }
216+
192217 /** @test */
193218 public function cancelShouldAlwaysTriggerCancellerWhenCalledOnRootPromise ()
194219 {
You can’t perform that action at this time.
0 commit comments