function testFromFailureHandler() { $ok = 0; $promise = new Promise(); $promise->otherwise(function ($reason) { $this->assertEquals('foo', $reason); throw new \Exception('hi'); })->then(function () use(&$ok) { $ok = -1; }, function () use(&$ok) { $ok = 1; }); $this->assertEquals(0, $ok); $promise->reject('foo'); Loop\run(); $this->assertEquals(1, $ok); }