Ejemplo n.º 1
0
 /**
  * @override
  * @inheritDoc
  */
 public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
 {
     if (null === $onCancel) {
         return $this;
     }
     try {
         return Promise::doResolve($onCancel($this->getReason()))->then(function () {
             return Promise::doCancel($this->getReason());
         }, function () {
             return Promise::doCancel($this->getReason());
         });
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     return Promise::doCancel($this->getReason());
 }
 /**
  *
  */
 public function testApiSpread_Returns_FromCancellationHandler_ForCancelledPromise()
 {
     $deferred = $this->createDeferred();
     $test = $this->getTest();
     $ex = new Exception('Error');
     $mock = $test->createCallableMock();
     $mock->expects($test->once())->method('__invoke')->with($test->identicalTo($ex));
     $deferred->cancel();
     $deferred->getPromise()->spread(null, null, function () use($ex) {
         return Promise::doCancel($ex);
     })->then(null, null, $mock);
 }
Ejemplo n.º 3
0
 /**
  *
  */
 public function testApiDoCancel_ReturnsPromise()
 {
     $test = $this->getTest();
     $test->assertInstanceOf(PromiseInterface::class, Promise::doCancel(1));
 }