1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 07:14: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

@ -33,7 +33,8 @@
"doctrine/dbal": "^3.6.0", "doctrine/dbal": "^3.6.0",
"spatie/valuestore": "^1.2.5", "spatie/valuestore": "^1.2.5",
"pestphp/pest": "^3.0", "pestphp/pest": "^3.0",
"larastan/larastan": "^3.0" "larastan/larastan": "^3.0",
"league/flysystem-path-prefixing": "^3.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View file

@ -200,3 +200,31 @@ test('tenant storage can get deleted after the tenant when DeletingTenant listen
expect(File::isDirectory($tenantStoragePath))->toBeFalse(); 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();
});