1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 12:04:02 +00:00

Add regression test

This commit is contained in:
lukinovec 2025-10-28 15:39:36 +01:00
parent e5b79ff603
commit 4173749069
2 changed files with 30 additions and 1 deletions

View file

@ -200,3 +200,31 @@ test('tenant storage can get deleted after the tenant when DeletingTenant listen
expect(File::isDirectory($tenantStoragePath))->toBeFalse();
});
test('scoped disks are scoped per tenant', function () {
config([
'tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
],
'filesystems.disks.scoped_disk' => [
'driver' => 'scoped',
'disk' => 'public',
'prefix' => 'scoped_disk_prefix',
],
]);
$tenant = Tenant::create();
$storagePath = storage_path() . "/tenant{$tenant->id}";
// Resolve scoped_disk before initializing tenancy
Storage::disk('scoped_disk');
tenancy()->initialize($tenant);
Storage::disk('scoped_disk')->put('foo.txt', 'foo text');
tenancy()->end();
expect(File::exists($storagePath . '/app/public/scoped_disk_prefix/foo.txt'))->toBeTrue();
});