1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-09-20 14:34:03 +00:00

Assert that symlinks work without a root_override and that disks with a null url_override are skipped (regression test)

This commit is contained in:
lukinovec 2026-08-19 15:10:07 +02:00 committed by Samuel Stancl
parent 79484cac09
commit aad435da44

View file

@ -19,7 +19,7 @@ beforeEach(function () {
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
});
test('create storage symlinks action works', function (string $rootOverride, bool $suffixStoragePath) {
test('create storage symlinks action works', function (string|null $rootOverride, bool $suffixStoragePath) {
config([
'tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
@ -53,6 +53,8 @@ test('create storage symlinks action works', function (string $rootOverride, boo
'default root_override' => ['%storage_path%/app/public/', true],
'suffix_storage_path disabled' => ['%storage_path%/app/public/', false],
'custom root_override' => ['%original_storage_path%/app/public/%tenant%/', true],
// Without a root_override, the bootstrapper suffixes the disk's central root
'no root_override' => [null, true],
]);
test('create storage symlinks action fails for disks that are not tenant-aware', function () {
@ -77,6 +79,28 @@ test('create storage symlinks action fails for disks that are not tenant-aware',
expect(is_link(public_path('public-' . $tenant->getTenantKey())))->toBeFalse();
});
test('create storage symlinks action skips disks with a null url_override', function () {
config([
'tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
],
'tenancy.filesystem.suffix_base' => 'tenant-',
'tenancy.filesystem.url_override' => [
'public' => 'public-%tenant%',
// A null override means the disk's URL is not overridden, same as in the FS bootstrapper
'local' => null,
],
]);
/** @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();
});
test('remove storage symlinks action works', function() {
config([
'tenancy.bootstrappers' => [