public function PromiseTest::testCancelsUppermostPendingPromise in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/promises/tests/PromiseTest.php \GuzzleHttp\Promise\Tests\PromiseTest::testCancelsUppermostPendingPromise()
File
- vendor/
guzzlehttp/ promises/ tests/ PromiseTest.php, line 203
Class
Namespace
GuzzleHttp\Promise\TestsCode
public function testCancelsUppermostPendingPromise() {
$called = false;
$p1 = new Promise(null, function () use (&$called) {
$called = true;
});
$p2 = $p1
->then(function () {
});
$p3 = $p2
->then(function () {
});
$p4 = $p3
->then(function () {
});
$p3
->cancel();
$this
->assertEquals('rejected', $p1
->getState());
$this
->assertEquals('rejected', $p2
->getState());
$this
->assertEquals('rejected', $p3
->getState());
$this
->assertEquals('pending', $p4
->getState());
$this
->assertTrue($called);
try {
$p3
->wait();
$this
->fail();
} catch (CancellationException $e) {
$this
->assertContains('cancelled', $e
->getMessage());
}
try {
$p4
->wait();
$this
->fail();
} catch (CancellationException $e) {
$this
->assertContains('cancelled', $e
->getMessage());
}
$this
->assertEquals('rejected', $p4
->getState());
}