From 80ee591515e5487eacce700fc1bc9b539a94b9dc Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sat, 7 Jan 2017 11:51:24 +0100 Subject: [PATCH] Test that throwing callback continues calling other whens --- src/Test.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Test.php b/src/Test.php index 7560310..1bd0e5d 100644 --- a/src/Test.php +++ b/src/Test.php @@ -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() {