1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

update to unlink not the current version but the currently linked formula path (handles bug with latest version under php path)

This commit is contained in:
James Barnard
2019-01-21 22:33:32 +00:00
committed by Matt Stauffer
parent ece3a1ff2f
commit 0bf3078220
4 changed files with 131 additions and 5 deletions

View File

@@ -371,4 +371,104 @@ public function test_getRunningServices_will_pass_to_brew_services_list_and_retu
'service3',
], array_values($result->all()));
}
/**
* @dataProvider supportedPhpLinkPathProvider
*
* @param $path
* @param $matches
*/
public function test_get_parsed_linked_php_will_return_matches_for_linked_php($path, $matches)
{
$getBrewMock = function ($filesystem) {
$brewMock = Mockery::mock(Brew::class, [new CommandLine, $filesystem])->makePartial();
$brewMock->shouldReceive('hasLinkedPhp')->once()->andReturn(true);
return $brewMock;
};
$files = Mockery::mock(Filesystem::class);
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn($path);
$this->assertSame($matches, $getBrewMock($files)->getParsedLinkedPhp());
}
/**
* @dataProvider supportedPhpLinkPathProvider
*
* @param $path
* @param $matches
* @param $expectedLinkFormula
*/
public function test_get_linked_php_formula_will_return_linked_php_directory($path, $matches, $expectedLinkFormula)
{
$brewMock = Mockery::mock(Brew::class)->makePartial();
$brewMock->shouldReceive('getParsedLinkedPhp')->andReturn($matches);
$this->assertSame($expectedLinkFormula, $brewMock->getLinkedPhpFormula());
}
/**
* Provider of php links and their expected split matches
*
* @return array
*/
public function supportedPhpLinkPathProvider()
{
return [
[
'/test/path/php/7.3.0/test', // linked path
[ // matches
'path/php/7.3.0/test',
'php',
'',
'7.3',
'.0',
],
'php', // expected link formula
],
[
'/test/path/php@7.2/7.2.13/test',
[
'path/php@7.2/7.2.13/test',
'php',
'@7.2',
'7.2',
'.13',
],
'php@7.2'
],
[
'/test/path/php/7.2.9_2/test',
[
'path/php/7.2.9_2/test',
'php',
'',
'7.2',
'.9_2',
],
'php',
],
[
'/test/path/php72/7.2.9_2/test',
[
'path/php72/7.2.9_2/test',
'php',
'72',
'7.2',
'.9_2',
],
'php72',
],
[
'/test/path/php56/test',
[
'path/php56/test',
'php',
'56',
'',
'',
],
'php56',
],
];
}
}

View File

@@ -118,7 +118,7 @@ public function test_use_version_if_already_linked_php_will_unlink_before_instal
'php@5.6',
]));
$brewMock->shouldReceive('hasLinkedPhp')->andReturn(true);
$brewMock->shouldReceive('linkedPhp')->andReturn('php@7.1');
$brewMock->shouldReceive('getLinkedPhpFormula')->andReturn('php@7.1');
$brewMock->shouldReceive('unlink')->with('php@7.1');
$brewMock->shouldReceive('ensureInstalled')->with('php@7.2');
$brewMock->shouldReceive('link')->withArgs(['php@7.2', true]);