File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-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
+ all ([
26
+ resolve (true ),
27
+ race ([
28
+ (new Promise (function ($ _ , $ reject ) use ($ input ) {
29
+ $ reject ($ input );
30
+ })),
31
+ (new Promise (function () {
32
+ })),
33
+ ])
34
+ ])->done ($ this ->expectCallableNever ());
35
+
36
+ $ errors = $ errorCollector ->stop ();
37
+
38
+ $ this ->assertEquals (E_USER_ERROR , $ errors [0 ]['errno ' ]);
39
+ $ this ->assertContains (
40
+ 'TypeError: Argument 1 passed to React\Promise\reject() must implement interface Throwable ' ,
41
+ $ errors [0 ]['errstr ' ]
42
+ );
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments