mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 16:10:08 +01:00
Merge remote-tracking branch 'upstream/master' into feat/proxy-multiple-domains
This commit is contained in:
@@ -11,9 +11,11 @@
|
||||
use Valet\Ngrok;
|
||||
use Valet\PhpFpm;
|
||||
use Valet\Site as RealSite;
|
||||
use function Valet\swap;
|
||||
use Valet\Valet;
|
||||
|
||||
use function Valet\resolve;
|
||||
use function Valet\swap;
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.0
|
||||
*/
|
||||
@@ -253,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 = 'php@8.2';
|
||||
|
||||
$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([
|
||||
'php@8.2',
|
||||
'php@8.1',
|
||||
]));
|
||||
|
||||
$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();
|
||||
@@ -776,7 +842,7 @@ public function test_stop_command()
|
||||
$tester->run(['command' => 'stop']);
|
||||
$tester->assertCommandIsSuccessful();
|
||||
|
||||
$this->assertStringContainsString('Valet services have been stopped.', $tester->getDisplay());
|
||||
$this->assertStringContainsString('Valet core services have been stopped.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function test_stop_command_stops_nginx()
|
||||
@@ -809,6 +875,21 @@ public function test_stop_command_stops_php()
|
||||
$this->assertStringContainsString('PHP has been stopped', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function test_stop_all_command_stops_dnsmasq()
|
||||
{
|
||||
[$app, $tester] = $this->appAndTester();
|
||||
|
||||
$phpfpm = Mockery::mock(DnsMasq::class);
|
||||
$phpfpm->shouldReceive('stop');
|
||||
|
||||
swap(DnsMasq::class, $phpfpm);
|
||||
|
||||
$tester->run(['command' => 'stop', 'service' => 'dnsmasq']);
|
||||
$tester->assertCommandIsSuccessful();
|
||||
|
||||
$this->assertStringContainsString('dnsmasq has been stopped', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function test_stop_command_handles_bad_services()
|
||||
{
|
||||
[$app, $tester] = $this->appAndTester();
|
||||
|
||||
Reference in New Issue
Block a user