Skip to content

Commit

Permalink
Functionally test enforcing Throwable as rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Apr 22, 2019
1 parent e5b5af1 commit 89fdfb3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/FunctionalRejectTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace React\Promise;

use stdClass;

class FunctionalRejectTest extends TestCase
{
public function nonThrowables()
{
yield '1' => [1];
yield 'true' => [true];
yield 'stdClass' => [new stdClass()];
}

/**
* @test
* @expectedException \TypeError
* @dataProvider nonThrowables
*/
public function shouldThrowWhenCalledWithANonException($input)
{
all([
resolve(true),
race([
(new Promise(function ($_, $reject) use ($input) {
$reject($input);
})),
(new Promise(function () {
})),
])
])->done($this->expectCallableNever());
}
}

0 comments on commit 89fdfb3

Please sign in to comment.