Example #1
0
 /**
  * @memcheck
  */
 public function testDeferredThenDeferred()
 {
     $d1 = new Deferred(function () {
         $this->data["d1.cancel"] = true;
     });
     $d2 = new Deferred(function () {
         $this->data["d2.cancel"] = true;
     });
     $d2->then(function ($result) {
         $this->data["result"] = $this->describe($result);
     }, function ($result) {
         $this->data["error"] = $this->describe($result);
     });
     $d1->then($d2);
     $d2->done("iddqd");
     $this->assertSame(['result' => "iddqd"], $this->data);
 }
Example #2
0
 /**
  * @expectedException \ION\InvalidUsageException
  * @expectedExceptionMessage Deferred has been finished
  * @memcheck
  */
 public function testRejectAfterFail()
 {
     $defer = new Deferred(function () {
     });
     $defer->then(function () {
     });
     $defer->fail(new \RuntimeException("errorka"));
     $defer->cancel("bad reason");
 }