Commit 86cfede 1 parent 9f54bcd commit 86cfede Copy full SHA for 86cfede
File tree 4 files changed +23
-3
lines changed
4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 14
14
"php" : " >=5.4" ,
15
15
"ext-sqlite3" : " *" ,
16
16
"clue/ndjson-react" : " ^1.0" ,
17
- "react/child-process" : " ^0.6" ,
17
+ "react/child-process" : " ^0.6.6 " ,
18
18
"react/event-loop" : " ^1.2" ,
19
- "react/promise" : " ^3 || ^2.7 || ^1.2.1"
19
+ "react/promise" : " ^3.2 || ^2.7 || ^1.2.1"
20
20
},
21
21
"require-dev" : {
22
22
"phpunit/phpunit" : " ^9.6 || ^5.7 || ^4.8.36"
Original file line number Diff line number Diff line change @@ -62,8 +62,12 @@ class Factory
62
62
* @param ?LoopInterface $loop
63
63
* @param ?string $binary
64
64
*/
65
- public function __construct (LoopInterface $ loop = null , $ binary = null )
65
+ public function __construct ($ loop = null , $ binary = null )
66
66
{
67
+ if ($ loop !== null && !$ loop instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
68
+ throw new \InvalidArgumentException ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
69
+ }
70
+
67
71
$ this ->loop = $ loop ?: Loop::get ();
68
72
$ this ->bin = $ binary === null ? $ this ->php () : $ binary ;
69
73
Original file line number Diff line number Diff line change @@ -32,6 +32,20 @@ public function testConstructWitLoopAndBinaryAssignsBothVariables()
32
32
$ this ->assertSame ('php6.0 ' , $ ref ->getValue ($ factory ));
33
33
}
34
34
35
+ public function testCtorThrowsForInvalidLoop ()
36
+ {
37
+ if (method_exists ($ this , 'expectException ' )) {
38
+ // PHPUnit 5.2+
39
+ $ this ->expectException ('InvalidArgumentException ' );
40
+ $ this ->expectExceptionMessage ('Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
41
+ } else {
42
+ // legacy PHPUnit
43
+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Argument #1 ($loop) expected null|React\EventLoop\LoopInterface ' );
44
+ }
45
+
46
+ new Factory ('loop ' );
47
+ }
48
+
35
49
public function testLoadLazyReturnsDatabaseImmediately ()
36
50
{
37
51
$ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ class BlockingDatabaseTest extends TestCase
9
9
public function testCtorThrowsForInvalidPath ()
10
10
{
11
11
if (method_exists ($ this , 'expectException ' )) {
12
+ // PHPUnit 5.2+
12
13
$ this ->expectException ('Exception ' );
13
14
} else {
15
+ // legacy PHPUnit
14
16
$ this ->setExpectedException ('Exception ' );
15
17
}
16
18
new BlockingDatabase ('/dev/foobar ' );
You can’t perform that action at this time.
0 commit comments