public function testPromiseThen__ThenRejectedByPromiseButResolved() { $result = new Client($this->store); $promise1 = new Client($this->store); $this->object = $promise1->then(null, function ($reason) { return $reason->getMessage() . ' was resolved'; }); $promise1->reject($result); $this->assertEquals($result->getId() . ' was resolved', $this->object->wait(false)); $this->assertEquals(PromiseInterface::FULFILLED, $this->object->getState()); }
function testWaitRejectedNonScalar() { $promise = new Promise(); Loop\nextTick(function () use($promise) { $promise->reject([]); }); try { $promise->wait(); $this->fail('We did not get the expected exception'); } catch (\Exception $e) { $this->assertInstanceOf('Exception', $e); $this->assertEquals('Promise was rejected with reason of type: array', $e->getMessage()); } }