1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Test that throwing callback continues calling other whens

This commit is contained in:
Niklas Keller 2017-01-07 11:51:24 +01:00
parent c3d94e642d
commit 80ee591515

View File

@ -223,8 +223,31 @@ abstract class Test extends \PHPUnit_Framework_TestCase {
$succeeder(true);
$this->assertEquals(4, $invoked);
}
Promise\ErrorHandler::set($original);
function testThrowingInCallbackContinuesOtherWhens() {
$invoked = 0;
Promise\ErrorHandler::set(function () use (&$invoked) {
$invoked++;
});
list($promise, $succeeder) = $this->promise();
$promise->when(function($e, $v) use (&$invoked, $promise) {
$this->assertSame(null, $e);
$this->assertSame(true, $v);
$invoked++;
throw new \Exception;
});
$promise->when(function($e, $v) use (&$invoked, $promise) {
$this->assertSame(null, $e);
$this->assertSame(true, $v);
$invoked++;
});
$succeeder(true);
$this->assertEquals(3, $invoked);
}
function testThrowingInCallbackOnFailure() {