File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Promise ;
4+
5+ use stdClass ;
6+
7+ class FunctionalRejectTest extends TestCase
8+ {
9+ public function nonThrowables ()
10+ {
11+ yield '1 ' => [1 ];
12+ yield 'true ' => [true ];
13+ yield 'stdClass ' => [new stdClass ()];
14+ }
15+
16+ /**
17+ * @test
18+ * @dataProvider nonThrowables
19+ */
20+ public function shouldThrowWhenCalledWithANonException ($ input )
21+ {
22+ $ errorCollector = new ErrorCollector ();
23+ $ errorCollector ->start ();
24+
25+ (new Promise (function ($ _ , $ reject ) use ($ input ) {
26+ $ reject ($ input );
27+ }))->done ($ this ->expectCallableNever ());
28+
29+ $ errors = $ errorCollector ->stop ();
30+
31+ $ this ->assertEquals (E_USER_ERROR , $ errors [0 ]['errno ' ]);
32+ $ this ->assertContains (
33+ 'TypeError: Argument 1 passed to React\Promise\reject() must implement interface Throwable ' ,
34+ $ errors [0 ]['errstr ' ]
35+ );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments