1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00

Modify php binary path to be based on brew prefix

This commit is contained in:
soilSpoon
2020-11-14 21:42:13 +09:00
parent c2fe653dd0
commit 6a4cb74392
3 changed files with 14 additions and 12 deletions

View File

@@ -202,7 +202,7 @@ function stopService($services)
*/
function hasLinkedPhp()
{
return $this->files->isLink('/usr/local/bin/php');
return $this->files->isLink(PHP_BINARY_PATH);
}
/**
@@ -216,7 +216,7 @@ function getParsedLinkedPhp()
throw new DomainException("Homebrew PHP appears not to be linked.");
}
$resolvedPath = $this->files->readLink('/usr/local/bin/php');
$resolvedPath = $this->files->readLink(PHP_BINARY_PATH);
/**
* Typical homebrew path resolutions are like:

View File

@@ -16,6 +16,8 @@
define('VALET_LEGACY_HOME_PATH', $_SERVER['HOME'].'/.valet');
define('PHP_BINARY_PATH', (new CommandLine())->runAsUser('echo $(brew --prefix)/bin/php'));
/**
* Output the given text to the console.
*

View File

@@ -238,27 +238,27 @@ public function test_linked_php_returns_linked_php_formula_name()
};
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php/7.4.0/test');
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php/7.4.0/test');
$this->assertSame('php@7.4', $getBrewMock($files)->linkedPhp());
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php/7.3.0/test');
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php/7.3.0/test');
$this->assertSame('php@7.3', $getBrewMock($files)->linkedPhp());
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php@7.2/7.2.13/test');
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php@7.2/7.2.13/test');
$this->assertSame('php@7.2', $getBrewMock($files)->linkedPhp());
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php/7.2.9_2/test');
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php/7.2.9_2/test');
$this->assertSame('php@7.2', $getBrewMock($files)->linkedPhp());
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php72/7.2.9_2/test');
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php72/7.2.9_2/test');
$this->assertSame('php@7.2', $getBrewMock($files)->linkedPhp());
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php56/test');
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php56/test');
$this->assertSame('php@5.6', $getBrewMock($files)->linkedPhp());
}
@@ -277,7 +277,7 @@ public function test_linked_php_throws_exception_if_no_php_link()
public function test_has_linked_php_returns_true_if_php_link_exists()
{
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('isLink')->twice()->with('/usr/local/bin/php')->andReturn(false, true);
$files->shouldReceive('isLink')->twice()->with(PHP_BINARY_PATH)->andReturn(false, true);
swap(Filesystem::class, $files);
$brew = resolve(Brew::class);
@@ -292,8 +292,8 @@ public function test_has_linked_php_returns_true_if_php_link_exists()
public function test_linked_php_throws_exception_if_unsupported_php_version_is_linked()
{
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php/5.4.14/test');
$files->shouldReceive('isLink')->once()->with(PHP_BINARY_PATH)->andReturn(true);
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn('/test/path/php/5.4.14/test');
swap(Filesystem::class, $files);
resolve(Brew::class)->linkedPhp();
}
@@ -449,7 +449,7 @@ public function test_get_parsed_linked_php_will_return_matches_for_linked_php($p
};
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn($path);
$files->shouldReceive('readLink')->once()->with(PHP_BINARY_PATH)->andReturn($path);
$this->assertSame($matches, $getBrewMock($files)->getParsedLinkedPhp());
}