Skip to content

Commit a98e778

Browse files
Furgasclue
authored andcommitted
Fix getting the type of unexpected reject reason
1 parent a4a5cd6 commit a98e778

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function ($error) use (&$exception, &$rejected, &$wait, $loop) {
8787
if ($rejected) {
8888
if (!$exception instanceof \Exception) {
8989
$exception = new \UnexpectedValueException(
90-
'Promise rejected with unexpected value of type ' . (is_object(($exception) ? get_class($exception) : gettype($exception))),
90+
'Promise rejected with unexpected value of type ' . (is_object($exception) ? get_class($exception) : gettype($exception)),
9191
0,
9292
$exception instanceof \Throwable ? $exception : null
9393
);

tests/FunctionAwaitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function testAwaitOneRejected()
1919

2020
/**
2121
* @expectedException UnexpectedValueException
22+
* @expectedExceptionMessage Promise rejected with unexpected value of type bool
2223
*/
2324
public function testAwaitOneRejectedWithFalseWillWrapInUnexpectedValueException()
2425
{
@@ -29,6 +30,7 @@ public function testAwaitOneRejectedWithFalseWillWrapInUnexpectedValueException(
2930

3031
/**
3132
* @expectedException UnexpectedValueException
33+
* @expectedExceptionMessage Promise rejected with unexpected value of type NULL
3234
*/
3335
public function testAwaitOneRejectedWithNullWillWrapInUnexpectedValueException()
3436
{
@@ -48,6 +50,7 @@ public function testAwaitOneRejectedWithPhp7ErrorWillWrapInUnexpectedValueExcept
4850
Block\await($promise, $this->loop);
4951
$this->fail();
5052
} catch (UnexpectedValueException $e) {
53+
$this->assertEquals('Promise rejected with unexpected value of type Error', $e->getMessage());
5154
$this->assertInstanceOf('Throwable', $e->getPrevious());
5255
$this->assertEquals('Test', $e->getPrevious()->getMessage());
5356
}

0 commit comments

Comments
 (0)