diff --git a/tests/FunctionalRejectTest.php b/tests/FunctionalRejectTest.php new file mode 100644 index 00000000..d303d7a4 --- /dev/null +++ b/tests/FunctionalRejectTest.php @@ -0,0 +1,37 @@ + [1]; + yield 'true' => [true]; + yield 'stdClass' => [new stdClass()]; + } + + /** + * @test + * @dataProvider nonThrowables + */ + public function shouldThrowWhenCalledWithANonException($input) + { + $errorCollector = new ErrorCollector(); + $errorCollector->start(); + + (new Promise(function ($_, $reject) use ($input) { + $reject($input); + }))->done($this->expectCallableNever()); + + $errors = $errorCollector->stop(); + + $this->assertEquals(E_USER_ERROR, $errors[0]['errno']); + $this->assertContains( + 'TypeError: Argument 1 passed to React\Promise\reject() must implement interface Throwable', + $errors[0]['errstr'] + ); + } +}