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

add tests for use version and return the found version to output

This commit is contained in:
James Barnard
2019-01-20 11:40:46 +00:00
committed by Matt Stauffer
parent 6158e5129b
commit 6a5c06e934
3 changed files with 86 additions and 15 deletions

View File

@@ -137,6 +137,7 @@ function stopRunning()
* Use a specific version of php
*
* @param $version
* @return string
*/
function useVersion($version)
{
@@ -147,18 +148,18 @@ function useVersion($version)
info(sprintf('Finding brew formula for: %s', $version));
$foundVersion = $this->brew->search($version)
->filter(function ($service) {
->first(function ($service) {
return $this->brew->supportedPhpVersions()->contains($service);
})
->first();
info(sprintf('Found brew formula: %s', $foundVersion));
});
if (!$this->brew->supportedPhpVersions()->contains($foundVersion)) {
if (is_null($foundVersion)) {
throw new DomainException(
sprintf('Valet doesn\'t support PHP version: %s', $foundVersion)
sprintf('Valet can\'t find a supported version of PHP for: %s', $version)
);
}
info(sprintf('Found brew formula: %s', $foundVersion));
if ($this->brew->hasLinkedPhp()) {
$currentVersion = $this->brew->linkedPhp();
info(sprintf('Unlinking current version: %s', $currentVersion));
@@ -171,5 +172,7 @@ function useVersion($version)
$this->brew->link($foundVersion, true);
$this->install();
return $foundVersion;
}
}

View File

@@ -282,10 +282,10 @@
$app->command('use phpVersion', function ($phpVersion) {
PhpFpm::stopRunning();
PhpFpm::useVersion($phpVersion);
$newVersion = PhpFpm::useVersion($phpVersion);
Nginx::restart();
info(sprintf('Valet is now using %s.', $phpVersion));
info(sprintf('Valet is now using %s.', $newVersion));
})->descriptions('Change the version of php used by valet', [
'phpVersion' => 'The PHP version you want to use, e.g php@7.2',
]);