mirror of
https://github.com/archtechx/tenancy.git
synced 2026-09-20 14:14:03 +00:00
Assert that TenantAssetController does not depend on storage_path() suffixing (regression test)
This commit is contained in:
parent
98d86478e7
commit
a9a727451e
1 changed files with 23 additions and 0 deletions
|
|
@ -65,6 +65,29 @@ test('asset can be accessed using the url returned by the tenant asset helper',
|
||||||
expect($content)->toBe('bar');
|
expect($content)->toBe('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('tenant assets are served even when the suffix_storage_path config is set to false', function () {
|
||||||
|
config([
|
||||||
|
'tenancy.identification.default_middleware' => InitializeTenancyByRequestData::class,
|
||||||
|
'tenancy.filesystem.suffix_storage_path' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// With suffix_storage_path disabled, storage_path() stays central in tenant context
|
||||||
|
$centralStoragePath = storage_path();
|
||||||
|
|
||||||
|
$tenant = Tenant::create();
|
||||||
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
|
$filename = 'testfile' . Str::random(8);
|
||||||
|
Storage::disk('public')->put($filename, 'bar');
|
||||||
|
|
||||||
|
$response = pest()->get(tenant_asset($filename), ['X-Tenant' => $tenant->id]);
|
||||||
|
|
||||||
|
// The asset is served from the tenant's storage directory, not from the central storage path
|
||||||
|
$response->assertSuccessful();
|
||||||
|
expect($response->getFile()->getPathname())
|
||||||
|
->toBe("$centralStoragePath/tenant{$tenant->id}/app/public/$filename");
|
||||||
|
});
|
||||||
|
|
||||||
test('asset helper returns a link to tenant asset controller when asset url is null', function () {
|
test('asset helper returns a link to tenant asset controller when asset url is null', function () {
|
||||||
config(['app.asset_url' => null]);
|
config(['app.asset_url' => null]);
|
||||||
config(['tenancy.filesystem.asset_helper_override' => true]);
|
config(['tenancy.filesystem.asset_helper_override' => true]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue