mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 18:44:04 +00:00
Add regression test for removing invalid symlinks
This commit is contained in:
parent
8960a83047
commit
6077053bbd
1 changed files with 37 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||||
use Stancl\Tenancy\Actions\CreateStorageSymlinksAction;
|
use Stancl\Tenancy\Actions\CreateStorageSymlinksAction;
|
||||||
use Stancl\Tenancy\Actions\RemoveStorageSymlinksAction;
|
use Stancl\Tenancy\Actions\RemoveStorageSymlinksAction;
|
||||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||||
|
|
@ -67,3 +68,39 @@ test('remove storage symlinks action works', function() {
|
||||||
|
|
||||||
$this->assertDirectoryDoesNotExist($publicPath);
|
$this->assertDirectoryDoesNotExist($publicPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('removing the tenant symlinks works even if the symlinks are invalid', function() {
|
||||||
|
// todo0 For this test to pass, delete the file_exists($link) check from symlinkExists() in DealsWithTenantSymlinks
|
||||||
|
config([
|
||||||
|
'tenancy.bootstrappers' => [
|
||||||
|
FilesystemTenancyBootstrapper::class,
|
||||||
|
],
|
||||||
|
'tenancy.filesystem.suffix_base' => 'tenant-',
|
||||||
|
'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/',
|
||||||
|
'tenancy.filesystem.url_override.public' => 'public-%tenant%'
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var Tenant $tenant */
|
||||||
|
$tenant = Tenant::create();
|
||||||
|
$tenantKey = $tenant->getTenantKey();
|
||||||
|
|
||||||
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
|
(new CreateStorageSymlinksAction)($tenant);
|
||||||
|
|
||||||
|
// The symlink exists and is valid
|
||||||
|
expect(is_link($publicPath = public_path("public-$tenantKey")))->toBeTrue();
|
||||||
|
expect(file_exists($publicPath))->toBeTrue();
|
||||||
|
|
||||||
|
// Make the symlink invalid by deleting the tenant storage directory
|
||||||
|
$storagePath = storage_path();
|
||||||
|
File::deleteDirectory($storagePath);
|
||||||
|
|
||||||
|
// The symlink still exists, but isn't valid
|
||||||
|
expect(is_link($publicPath))->toBeTrue();
|
||||||
|
expect(file_exists($publicPath))->toBeFalse();
|
||||||
|
|
||||||
|
(new RemoveStorageSymlinksAction)($tenant);
|
||||||
|
|
||||||
|
expect(is_link($publicPath))->toBeFalse();
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue