Skip to content

Commit c3aaae0

Browse files
fix: valet with no paths configured (#388)
* fix: valet with no paths configured * refactor: fix style * refactor: rename test file * refactor: remove return types * Update InteractsWithHerdOrValet.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 107b3af commit c3aaae0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Concerns/InteractsWithHerdOrValet.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public function isParkedOnHerdOrValet(string $directory)
1717
{
1818
$output = $this->runOnValetOrHerd('paths');
1919

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);
2123
}
2224

2325
/**
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

0 commit comments

Comments
 (0)