mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 08:24:03 +00:00
Add DeleteTenantStorage listener
This commit is contained in:
parent
624f032775
commit
29ba72fe53
5 changed files with 44 additions and 7 deletions
|
|
@ -23,6 +23,7 @@ use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
|||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Events\TenantDeleted;
|
||||
use Stancl\Tenancy\Listeners\DeleteTenantStorage;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->mockConsoleOutput = false;
|
||||
|
|
@ -186,19 +187,14 @@ test('filesystem data is separated', function () {
|
|||
expect($new_storage_path)->toEqual($expected_storage_path);
|
||||
});
|
||||
|
||||
test('tenant storage gets deleted after the tenant if filesystem.delete_storage_after_tenant_deletion is true', function () {
|
||||
test('tenant storage gets deleted after the tenant', function () {
|
||||
config([
|
||||
'tenancy.bootstrappers' => [
|
||||
FilesystemTenancyBootstrapper::class,
|
||||
],
|
||||
'tenancy.filesystem.delete_storage_after_tenant_deletion' => true
|
||||
]);
|
||||
|
||||
Event::listen(TenantDeleted::class, function(TenantDeleted $event) {
|
||||
if (config('tenancy.filesystem.delete_storage_after_tenant_deletion')) {
|
||||
File::deleteDirectory($event->tenant->run(fn () => storage_path()));
|
||||
}
|
||||
});
|
||||
Event::listen(TenantDeleted::class, DeleteTenantStorage::class);
|
||||
|
||||
tenancy()->initialize(Tenant::create());
|
||||
$tenantStoragePath = storage_path();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue