File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,11 +128,14 @@ public function cancel()
128128 return ;
129129 }
130130
131+ $ canceller = $ this ->canceller ;
132+ $ this ->canceller = null ;
133+
131134 try {
132135 $ that = $ this ;
133136
134137 call_user_func (
135- $ this -> canceller ,
138+ $ canceller ,
136139 function ($ value = null ) use ($ that ) {
137140 $ that ->resolve ($ value );
138141 },
Original file line number Diff line number Diff line change @@ -114,6 +114,14 @@ public function shouldInvokeCancellationHandlerAndStayPendingWhenCallingCancel()
114114 $ d ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
115115 }
116116
117+ /** @test */
118+ public function shouldInvokeCancellationHandlerOnlyOnceWhenCallingCancelMultipleTimes ()
119+ {
120+ $ d = new Deferred ($ this ->expectCallableOnce ());
121+ $ d ->cancel ();
122+ $ d ->cancel ();
123+ }
124+
117125 /** @test */
118126 public function shouldResolveWhenCancellationHandlerResolves ()
119127 {
You can’t perform that action at this time.
0 commit comments