[ FilesystemTenancyBootstrapper::class, ], 'tenancy.filesystem.suffix_base' => 'tenant-', 'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/', 'tenancy.filesystem.url_override.public' => 'public-%tenant_id%' ]); /** @var \Stancl\Tenancy\Database\Models\Tenant $tenant */ $tenant = Tenant::create(); $tenantKey = $tenant->getTenantKey(); tenancy()->initialize($tenant); Storage::disk('public')->put('test.txt', 'test'); $this->assertDirectoryDoesNotExist(public_path("public-$tenantKey")); CreateStorageSymlinksAction::handle($tenant); $this->assertDirectoryExists(storage_path("app/public")); $this->assertDirectoryExists(public_path("public-$tenantKey")); $this->assertEquals(storage_path("app/public/"), readlink(public_path("public-$tenantKey"))); }); test('remove storage symlinks action works', function() { config([ 'tenancy.bootstrappers' => [ FilesystemTenancyBootstrapper::class, ], 'tenancy.filesystem.suffix_base' => 'tenant-', 'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/', 'tenancy.filesystem.url_override.public' => 'public-%tenant_id%' ]); /** @var \Stancl\Tenancy\Database\Models\Tenant $tenant */ $tenant = Tenant::create(); $tenantKey = $tenant->getTenantKey(); tenancy()->initialize($tenant); CreateStorageSymlinksAction::handle($tenant); RemoveStorageSymlinksAction::handle($tenant); $this->assertDirectoryDoesNotExist(public_path("public-$tenantKey")); });