-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1428 from mcaskill/improve-link-subcommands
Fix link command's `--isolate` argument with custom name
- Loading branch information
Showing
3 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
use Valet\Nginx; | ||
use Valet\Ngrok; | ||
use Valet\PhpFpm; | ||
use function Valet\resolve; | ||
use Valet\Site as RealSite; | ||
use Valet\Valet; | ||
|
||
|
@@ -254,6 +255,70 @@ public function test_link_command_with_secure_flag_secures() | |
$this->assertStringContainsString('site has been secured', $tester->getDisplay()); | ||
} | ||
|
||
public function test_link_command_with_isolate_flag_isolates() | ||
{ | ||
[$app, $tester] = $this->appAndTester(); | ||
|
||
$cwd = getcwd(); | ||
$name = 'tighten'; | ||
$host = $name.'.test'; | ||
|
||
$customPhpVersion = '82'; | ||
$phpRcVersion = '8.2'; | ||
$fullPhpVersion = '[email protected]'; | ||
|
||
$brewMock = Mockery::mock(Brew::class); | ||
$nginxMock = Mockery::mock(Nginx::class); | ||
$siteMock = Mockery::mock(RealSite::class); | ||
|
||
$phpFpmMock = Mockery::mock(PhpFpm::class, [ | ||
$brewMock, | ||
resolve(CommandLine::class), | ||
resolve(Filesystem::class), | ||
resolve(RealConfiguration::class), | ||
$siteMock, | ||
$nginxMock, | ||
])->makePartial(); | ||
|
||
swap(Brew::class, $brewMock); | ||
swap(Nginx::class, $nginxMock); | ||
swap(PhpFpm::class, $phpFpmMock); | ||
swap(RealSite::class, $siteMock); | ||
|
||
$brewMock->shouldReceive('supportedPhpVersions')->andReturn(collect([ | ||
'[email protected]', | ||
'[email protected]', | ||
])); | ||
|
||
$brewMock->shouldReceive('ensureInstalled')->with($fullPhpVersion, [], $phpFpmMock->taps); | ||
$brewMock->shouldReceive('installed')->with($fullPhpVersion); | ||
$brewMock->shouldReceive('determineAliasedVersion')->with($fullPhpVersion)->andReturn($fullPhpVersion); | ||
|
||
$siteMock->shouldReceive('link')->with($cwd, $name)->once(); | ||
$siteMock->shouldReceive('getSiteUrl')->with($name)->andReturn($host); | ||
$siteMock->shouldReceive('phpRcVersion')->with($name, $cwd)->andReturn($phpRcVersion); | ||
$siteMock->shouldReceive('customPhpVersion')->with($host)->andReturn($customPhpVersion); | ||
$siteMock->shouldReceive('isolate')->with($host, $fullPhpVersion); | ||
|
||
$phpFpmMock->shouldReceive('stopIfUnused')->with($customPhpVersion)->once(); | ||
$phpFpmMock->shouldReceive('createConfigurationFiles')->with($fullPhpVersion)->once(); | ||
$phpFpmMock->shouldReceive('restart')->with($fullPhpVersion)->once(); | ||
|
||
$nginxMock->shouldReceive('restart')->once(); | ||
|
||
// These should only run when doing global PHP switches | ||
$brewMock->shouldNotReceive('stopService'); | ||
$brewMock->shouldNotReceive('link'); | ||
$brewMock->shouldNotReceive('unlink'); | ||
$phpFpmMock->shouldNotReceive('stopRunning'); | ||
$phpFpmMock->shouldNotReceive('install'); | ||
|
||
$tester->run(['command' => 'link', 'name' => 'tighten', '--isolate' => true]); | ||
$tester->assertCommandIsSuccessful(); | ||
|
||
$this->assertStringContainsString('is now using '.$fullPhpVersion, $tester->getDisplay()); | ||
} | ||
|
||
public function test_links_command() | ||
{ | ||
[$app, $tester] = $this->appAndTester(); | ||
|