mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 13:34:04 +00:00
Move falsy url_override assertions to more appropriate places
This commit is contained in:
parent
e3ba445630
commit
4af473ede5
2 changed files with 28 additions and 31 deletions
|
|
@ -28,7 +28,11 @@ test('create storage symlinks action works', function (string|null $rootOverride
|
||||||
// The disk root is suffixed regardless of the suffix_storage_path config
|
// The disk root is suffixed regardless of the suffix_storage_path config
|
||||||
'tenancy.filesystem.suffix_storage_path' => $suffixStoragePath,
|
'tenancy.filesystem.suffix_storage_path' => $suffixStoragePath,
|
||||||
'tenancy.filesystem.root_override.public' => $rootOverride,
|
'tenancy.filesystem.root_override.public' => $rootOverride,
|
||||||
'tenancy.filesystem.url_override.public' => 'public-%tenant%'
|
'tenancy.filesystem.url_override' => [
|
||||||
|
'public' => 'public-%tenant%',
|
||||||
|
// Disks with a falsy url_override are skipped
|
||||||
|
'local' => '',
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/** @var Tenant $tenant */
|
/** @var Tenant $tenant */
|
||||||
|
|
@ -49,6 +53,9 @@ test('create storage symlinks action works', function (string|null $rootOverride
|
||||||
expect(is_link($publicPath))->toBeTrue();
|
expect(is_link($publicPath))->toBeTrue();
|
||||||
expect(readlink($publicPath))->toBe(config('filesystems.disks.public.root'));
|
expect(readlink($publicPath))->toBe(config('filesystems.disks.public.root'));
|
||||||
expect(file_get_contents($publicPath . '/foo.txt'))->toBe('tenant file');
|
expect(file_get_contents($publicPath . '/foo.txt'))->toBe('tenant file');
|
||||||
|
|
||||||
|
// The local disk is skipped because its url_override is '' -- no symlink is created at public_path('')
|
||||||
|
expect(is_link(public_path('')))->toBeFalse();
|
||||||
})->with([
|
})->with([
|
||||||
'default root_override' => ['%storage_path%/app/public/', true],
|
'default root_override' => ['%storage_path%/app/public/', true],
|
||||||
'suffix_storage_path disabled' => ['%storage_path%/app/public/', false],
|
'suffix_storage_path disabled' => ['%storage_path%/app/public/', false],
|
||||||
|
|
@ -79,36 +86,6 @@ test('create storage symlinks action fails for disks that are not tenant-aware',
|
||||||
expect(is_link(public_path('public-' . $tenant->getTenantKey())))->toBeFalse();
|
expect(is_link(public_path('public-' . $tenant->getTenantKey())))->toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create storage symlinks action skips disks with no url_override', function (string|null $localUrlOverride) {
|
|
||||||
config([
|
|
||||||
'tenancy.bootstrappers' => [
|
|
||||||
FilesystemTenancyBootstrapper::class,
|
|
||||||
],
|
|
||||||
'tenancy.filesystem.suffix_base' => 'tenant-',
|
|
||||||
'tenancy.filesystem.url_override' => [
|
|
||||||
'public' => 'public-%tenant%',
|
|
||||||
'local' => $localUrlOverride,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
/** @var Tenant $tenant */
|
|
||||||
$tenant = Tenant::create();
|
|
||||||
|
|
||||||
(new CreateStorageSymlinksAction)($tenant);
|
|
||||||
|
|
||||||
// The local disk is skipped, so the public disk still gets its symlink
|
|
||||||
expect(is_link(public_path('public-' . $tenant->getTenantKey())))->toBeTrue();
|
|
||||||
|
|
||||||
// The bootstrapper skips the same disk, so its URL is not overridden either
|
|
||||||
$centralUrl = config('filesystems.disks.local.url');
|
|
||||||
tenancy()->initialize($tenant);
|
|
||||||
|
|
||||||
expect(config('filesystems.disks.local.url'))->toBe($centralUrl);
|
|
||||||
})->with([
|
|
||||||
'null url_override' => [null],
|
|
||||||
'empty url_override' => [''],
|
|
||||||
]);
|
|
||||||
|
|
||||||
test('remove storage symlinks action works', function() {
|
test('remove storage symlinks action works', function() {
|
||||||
config([
|
config([
|
||||||
'tenancy.bootstrappers' => [
|
'tenancy.bootstrappers' => [
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,26 @@ test('links to storage disks with a configured root are suffixed if not overridd
|
||||||
expect(storage_path())->toEqual($expectedStoragePath);
|
expect(storage_path())->toEqual($expectedStoragePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('disks with a falsy url_override do not get their url overridden', function ($urlOverride) {
|
||||||
|
config([
|
||||||
|
'tenancy.bootstrappers' => [
|
||||||
|
FilesystemTenancyBootstrapper::class,
|
||||||
|
],
|
||||||
|
'tenancy.filesystem.url_override.public' => $urlOverride,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tenant = Tenant::create();
|
||||||
|
|
||||||
|
$centralUrl = config('filesystems.disks.public.url');
|
||||||
|
|
||||||
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
|
expect(config('filesystems.disks.public.url'))->toBe($centralUrl);
|
||||||
|
})->with([
|
||||||
|
'empty string' => [''],
|
||||||
|
'null' => [null],
|
||||||
|
]);
|
||||||
|
|
||||||
test('create and delete storage symlinks jobs work', function() {
|
test('create and delete storage symlinks jobs work', function() {
|
||||||
Event::listen(
|
Event::listen(
|
||||||
TenantCreated::class,
|
TenantCreated::class,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue