|
13 | 13 | use Stancl\Tenancy\Jobs\CreateStorageSymlinks; |
14 | 14 | use Stancl\Tenancy\Jobs\RemoveStorageSymlinks; |
15 | 15 | use Stancl\Tenancy\Listeners\BootstrapTenancy; |
| 16 | +use Stancl\Tenancy\Jobs\CreateTenantStorage; |
16 | 17 | use Stancl\Tenancy\Jobs\DeleteTenantStorage; |
17 | 18 | use Stancl\Tenancy\Listeners\RevertToCentralContext; |
18 | 19 | use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper; |
|
184 | 185 | $this->assertDirectoryDoesNotExist(public_path("public-$tenantKey")); |
185 | 186 | }); |
186 | 187 |
|
| 188 | +test('tenant storage gets created when TenantCreated listens to CreateTenantStorage', function() { |
| 189 | + config([ |
| 190 | + 'tenancy.bootstrappers' => [ |
| 191 | + FilesystemTenancyBootstrapper::class, |
| 192 | + ], |
| 193 | + ]); |
| 194 | + |
| 195 | + Event::listen(TenantCreated::class, |
| 196 | + JobPipeline::make([CreateTenantStorage::class])->send(function (TenantCreated $event) { |
| 197 | + return $event->tenant; |
| 198 | + })->shouldBeQueued(false)->toListener() |
| 199 | + ); |
| 200 | + |
| 201 | + $centralStoragePath = storage_path(); |
| 202 | + $tenant = Tenant::create(); |
| 203 | + $tenantStoragePath = $centralStoragePath . '/tenant' . $tenant->getTenantKey(); |
| 204 | + |
| 205 | + $this->assertDirectoryExists($tenantStoragePath . '/framework/cache'); |
| 206 | +}); |
| 207 | + |
187 | 208 | test('tenant storage can get deleted after the tenant when DeletingTenant listens to DeleteTenantStorage', function() { |
188 | 209 | Event::listen(DeletingTenant::class, |
189 | 210 | JobPipeline::make([DeleteTenantStorage::class])->send(function (DeletingTenant $event) { |
|
260 | 281 | expect(file_get_contents(storage_path() . "/app/public/scoped_disk_prefix/foo.txt"))->toBe('central2'); |
261 | 282 | expect(file_get_contents(storage_path() . "/tenant{$tenant->id}/app/public/scoped_disk_prefix/foo.txt"))->toBe('tenant'); |
262 | 283 | }); |
263 | | - |
|
0 commit comments