From af3812e7885cffc3de86965bb957af663b70ac54 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 16 Aug 2023 09:03:25 +0200 Subject: [PATCH] Fix filesystem bootstrapper (#7) * Test if Storage::url() works correctly after reverting to central context * Fix typo in code * Access originalPaths using dot notation using `data_get()` --- src/Bootstrappers/FilesystemTenancyBootstrapper.php | 4 ++-- tests/BootstrapperTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Bootstrappers/FilesystemTenancyBootstrapper.php b/src/Bootstrappers/FilesystemTenancyBootstrapper.php index e9e0d93d..2dbba369 100644 --- a/src/Bootstrappers/FilesystemTenancyBootstrapper.php +++ b/src/Bootstrappers/FilesystemTenancyBootstrapper.php @@ -109,10 +109,10 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper $diskConfig = $this->app['config']['filesystems.disks.' . $diskName]; // Storage Url - $url = $this->originalPaths['disks.url.' . $diskName] ?? null; + $url = data_get($this->originalPaths, "disks.url.$diskName"); if ($diskConfig['driver'] === 'local' && ! is_null($url)) { - $$this->app['config']["filesystems.disks.$diskName.url"] = $url; + $this->app['config']["filesystems.disks.$diskName.url"] = $url; } } } diff --git a/tests/BootstrapperTest.php b/tests/BootstrapperTest.php index 96ae90a5..4cab7ddf 100644 --- a/tests/BootstrapperTest.php +++ b/tests/BootstrapperTest.php @@ -298,6 +298,15 @@ test('files can get fetched using the storage url', function() { $parsedUrl = Str::of($url)->after($hostname); expect(file_get_contents(public_path($parsedUrl)))->toBe($tenantKey); + + // Central + tenancy()->end(); + Storage::disk('public')->put($centralFileName = 'central.txt', $centralFileContent = 'central'); + + pest()->artisan('storage:link'); + $url = Storage::disk('public')->url($centralFileName); + + expect(file_get_contents(public_path($url)))->toBe($centralFileContent); }); test('create and delete storage symlinks jobs work', function() {