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

Update unlink command to also unsecure, if necessary

This commit is contained in:
Matt Stauffer
2023-02-10 18:46:58 -05:00
parent 21587b7f07
commit 0e9060d0a6
4 changed files with 75 additions and 4 deletions

View File

@@ -269,6 +269,18 @@ public function test_unlink_command()
{
[$app, $tester] = $this->appAndTester();
Site::link(getcwd(), basename(getcwd()));
$tester->run(['command' => 'unlink']);
$tester->assertCommandIsSuccessful();
$this->assertEquals(0, Site::links()->count());
}
public function test_unlink_command_with_parameter()
{
[$app, $tester] = $this->appAndTester();
Site::link(__DIR__.'/fixtures/Parked/Sites/my-best-site', 'tighten');
$tester->run(['command' => 'unlink', 'name' => 'tighten']);
@@ -277,6 +289,27 @@ public function test_unlink_command()
$this->assertEquals(0, Site::links()->count());
}
public function test_unlink_command_unsecures_as_well()
{
[$app, $tester] = $this->appAndTester();
Site::link(__DIR__.'/fixtures/Parked/Sites/my-best-site', 'tighten');
$site = Mockery::mock(RealSite::class);
$site->shouldReceive('domain')->with('tighten')->once()->andReturn('tighten.test');
$site->shouldReceive('unlink')->with('tighten')->once()->andReturn('tighten');
$site->shouldReceive('unsecure')->with('tighten.test')->once();
$site->shouldReceive('isSecured')->with('tighten')->once()->andReturn(true);
swap(RealSite::class, $site);
$nginx = Mockery::mock(Nginx::class);
$nginx->shouldReceive('restart')->once();
swap(Nginx::class, $nginx);
$tester->run(['command' => 'unlink', 'name' => 'tighten']);
$tester->assertCommandIsSuccessful();
}
public function test_secure_command()
{
[$app, $tester] = $this->appAndTester();