mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
This adds support for tenancy aware Storage::url() method
This commit is contained in:
parent
20e1fa1959
commit
adf3daa022
7 changed files with 196 additions and 3 deletions
|
|
@ -210,5 +210,32 @@ class BootstrapperTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function filesystem_local_storage_has_own_public_url()
|
||||
{
|
||||
config([
|
||||
'tenancy.bootstrappers' => [
|
||||
FilesystemTenancyBootstrapper::class,
|
||||
],
|
||||
'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/',
|
||||
'tenancy.filesystem.url_override.public' => 'storage-%tenant_id%'
|
||||
]);
|
||||
|
||||
$tenant1 = Tenant::create();
|
||||
$tenant2 = Tenant::create();
|
||||
|
||||
tenancy()->initialize($tenant1);
|
||||
$this->assertEquals(
|
||||
'http://localhost/storage-'.$tenant1->getTenantKey().'/',
|
||||
Storage::disk('public')->url('')
|
||||
);
|
||||
|
||||
tenancy()->initialize($tenant2);
|
||||
$this->assertEquals(
|
||||
'http://localhost/storage-'.$tenant2->getTenantKey().'/',
|
||||
Storage::disk('public')->url('')
|
||||
);
|
||||
}
|
||||
|
||||
// for queues see QueueTest
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,11 @@ class CommandsTest extends TestCase
|
|||
|
||||
config(['tenancy.bootstrappers' => [
|
||||
DatabaseTenancyBootstrapper::class,
|
||||
]]);
|
||||
],
|
||||
'tenancy.filesystem.suffix_base' => 'tenant-',
|
||||
'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/',
|
||||
'tenancy.filesystem.url_override.public' => 'storage-%tenant_id%'
|
||||
]);
|
||||
|
||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||
|
|
@ -202,4 +206,17 @@ class CommandsTest extends TestCase
|
|||
->expectsOutput('Tenant: ' . $tenantId1)
|
||||
->expectsOutput('Tenant: ' . $tenantId2);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function link_command_works()
|
||||
{
|
||||
$tenantId1 = Tenant::create()->getTenantKey();
|
||||
$tenantId2 = Tenant::create()->getTenantKey();
|
||||
Artisan::call('tenants:link');
|
||||
|
||||
$this->assertDirectoryExists(storage_path("tenant-$tenantId1/app/public"));
|
||||
$this->assertDirectoryExists(public_path("storage-$tenantId1"));
|
||||
$this->assertDirectoryExists(storage_path("tenant-$tenantId2/app/public"));
|
||||
$this->assertDirectoryExists(public_path("storage-$tenantId2"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue