File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ public function isParkedOnHerdOrValet(string $directory)
17
17
{
18
18
$ output = $ this ->runOnValetOrHerd ('paths ' );
19
19
20
- return $ output !== false ? in_array (dirname ($ directory ), json_decode ($ output )) : false ;
20
+ $ decodedOutput = json_decode ($ output );
21
+
22
+ return is_array ($ decodedOutput ) && in_array (dirname ($ directory ), $ decodedOutput );
21
23
}
22
24
23
25
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Laravel \Installer \Console \Concerns \InteractsWithHerdOrValet ;
4
+ use PHPUnit \Framework \TestCase ;
5
+
6
+ class InteractsWithHerdOrValetTest extends TestCase
7
+ {
8
+ use InteractsWithHerdOrValet;
9
+
10
+ public function test_isParkedOnHerdOrValet_returns_false_when_output_is_not_json ()
11
+ {
12
+ $ mockProcess = $ this ->getMockBuilder (\Symfony \Component \Process \Process::class)
13
+ ->disableOriginalConstructor ()
14
+ ->getMock ();
15
+ $ mockProcess ->method ('isSuccessful ' )->willReturn (true );
16
+ $ mockProcess ->method ('getOutput ' )->willReturn ('No paths have been registered. ' );
17
+
18
+ $ this ->assertFalse ($ this ->isParkedOnHerdOrValet ('paths ' ));
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments