mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
Rewrite TLS Caddy files on install
Porting this from master branch for now, makes it a lot easier for people to go from master to 1.1.* since the master branch has a different Caddyfile structure. Since Caddy 0.9.* still has the X-Accel-Redirect issue re: Content-Type, we can't tag on master yet, so this will help people get back to a tagged release without having to manually fix a bunch of Caddyfiles.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Valet\Site;
|
||||
use Valet\Caddy;
|
||||
use Valet\Filesystem;
|
||||
use Valet\Configuration;
|
||||
use Illuminate\Container\Container;
|
||||
|
||||
class CaddyTest extends PHPUnit_Framework_TestCase
|
||||
@@ -27,7 +29,7 @@ public function test_install_caddy_file_places_stub_in_valet_home_directory()
|
||||
$files->shouldReceive('putAsUser')->andReturnUsing(function ($path, $contents) {
|
||||
$this->assertSame(VALET_HOME_PATH.'/Caddyfile', $path);
|
||||
$this->assertTrue(strpos($contents, 'import '.VALET_HOME_PATH.'/Caddy/*') !== false);
|
||||
});
|
||||
})->once();
|
||||
|
||||
swap(Filesystem::class, $files);
|
||||
$caddy = resolve(Caddy::class);
|
||||
@@ -39,10 +41,12 @@ public function test_install_caddy_directories_creates_location_for_site_specifi
|
||||
{
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
$files->shouldReceive('isDir')->with(VALET_HOME_PATH.'/Caddy')->andReturn(false);
|
||||
$files->shouldReceive('mkdirAsUser')->with(VALET_HOME_PATH.'/Caddy');
|
||||
$files->shouldReceive('putAsUser')->with(VALET_HOME_PATH.'/Caddy/.keep', "\n");
|
||||
$files->shouldReceive('mkdirAsUser')->with(VALET_HOME_PATH.'/Caddy')->once();
|
||||
$files->shouldReceive('putAsUser')->with(VALET_HOME_PATH.'/Caddy/.keep', "\n")->once();
|
||||
|
||||
swap(Filesystem::class, $files);
|
||||
swap(Configuration::class, Mockery::spy(Configuration::class));
|
||||
swap(Site::class, Mockery::spy(Site::class));
|
||||
$caddy = resolve(Caddy::class);
|
||||
|
||||
$caddy->installCaddyDirectory();
|
||||
@@ -54,9 +58,11 @@ public function test_caddy_directory_is_never_created_if_it_already_exists()
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
$files->shouldReceive('isDir')->with(VALET_HOME_PATH.'/Caddy')->andReturn(true);
|
||||
$files->shouldReceive('mkdirAsUser')->never();
|
||||
$files->shouldReceive('putAsUser')->with(VALET_HOME_PATH.'/Caddy/.keep', "\n");
|
||||
$files->shouldReceive('putAsUser')->with(VALET_HOME_PATH.'/Caddy/.keep', "\n")->once();
|
||||
|
||||
swap(Filesystem::class, $files);
|
||||
swap(Configuration::class, Mockery::spy(Configuration::class));
|
||||
swap(Site::class, Mockery::spy(Site::class));
|
||||
$caddy = resolve(Caddy::class);
|
||||
|
||||
$caddy->installCaddyDirectory();
|
||||
@@ -68,12 +74,14 @@ public function test_caddy_daemon_is_placed_in_correct_location()
|
||||
$files = Mockery::mock(Filesystem::class.'[put]');
|
||||
|
||||
swap(Filesystem::class, $files);
|
||||
swap(Configuration::class, Mockery::spy(Configuration::class));
|
||||
swap(Site::class, Mockery::spy(Site::class));
|
||||
$caddy = resolve(Caddy::class);
|
||||
|
||||
$files->shouldReceive('put')->andReturnUsing(function ($path, $contents) use ($caddy) {
|
||||
$this->assertSame($caddy->daemonPath, $path);
|
||||
$this->assertTrue(strpos($contents, VALET_HOME_PATH) !== false);
|
||||
});
|
||||
})->once();
|
||||
|
||||
$caddy->installCaddyDaemon();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user