mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 13:34:04 +00:00
Refactor scoped disks test
Remove redundant config(['filesystem.disks.public.prefix' => 'scoped_disk_prefix']); line, try making the test less dense.
This commit is contained in:
parent
496e0c36bd
commit
45100453c5
1 changed files with 9 additions and 14 deletions
|
|
@ -268,32 +268,27 @@ test('scoped disks are scoped per tenant', function (bool $nested) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$disk = $nested ? 'nested_disk' : 'scoped_disk';
|
$disk = $nested ? 'nested_disk' : 'scoped_disk';
|
||||||
$prefix = $nested ? 'scoped_disk_prefix/nested_disk_prefix' : 'scoped_disk_prefix';
|
$path = 'app/public/scoped_disk_prefix/' . ($nested ? 'nested_disk_prefix/' : '') . 'foo.txt';
|
||||||
|
|
||||||
$tenant = Tenant::create();
|
$tenant = Tenant::create();
|
||||||
|
$centralFile = storage_path($path);
|
||||||
|
$tenantFile = storage_path("tenant{$tenant->id}/$path");
|
||||||
|
|
||||||
Storage::disk($disk)->put('foo.txt', 'central');
|
Storage::disk($disk)->put('foo.txt', 'central');
|
||||||
|
expect(file_get_contents($centralFile))->toBe('central');
|
||||||
config(['filesystem.disks.public.prefix' => 'scoped_disk_prefix']);
|
|
||||||
|
|
||||||
expect(Storage::disk($disk)->get('foo.txt'))->toBe('central');
|
|
||||||
expect(file_get_contents(storage_path() . "/app/public/{$prefix}/foo.txt"))->toBe('central');
|
|
||||||
|
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
expect(Storage::disk($disk)->get('foo.txt'))->toBe(null);
|
expect(Storage::disk($disk)->get('foo.txt'))->toBeNull();
|
||||||
|
|
||||||
Storage::disk($disk)->put('foo.txt', 'tenant');
|
Storage::disk($disk)->put('foo.txt', 'tenant');
|
||||||
expect(file_get_contents(storage_path() . "/app/public/{$prefix}/foo.txt"))->toBe('tenant');
|
expect(file_get_contents($tenantFile))->toBe('tenant');
|
||||||
expect(Storage::disk($disk)->get('foo.txt'))->toBe('tenant');
|
|
||||||
|
|
||||||
tenancy()->end();
|
tenancy()->end();
|
||||||
|
|
||||||
expect(Storage::disk($disk)->get('foo.txt'))->toBe('central');
|
expect(Storage::disk($disk)->get('foo.txt'))->toBe('central');
|
||||||
Storage::disk($disk)->put('foo.txt', 'central2');
|
expect(file_get_contents($centralFile))->toBe('central');
|
||||||
expect(Storage::disk($disk)->get('foo.txt'))->toBe('central2');
|
expect(file_get_contents($tenantFile))->toBe('tenant');
|
||||||
|
|
||||||
expect(file_get_contents(storage_path() . "/app/public/{$prefix}/foo.txt"))->toBe('central2');
|
|
||||||
expect(file_get_contents(storage_path() . "/tenant{$tenant->id}/app/public/{$prefix}/foo.txt"))->toBe('tenant');
|
|
||||||
})->with([
|
})->with([
|
||||||
'scoped disk' => false,
|
'scoped disk' => false,
|
||||||
'nested scoped disk' => true,
|
'nested scoped disk' => true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue