From e133c87c666b3a0d58321ec4dcd116d4f6b8f4dd Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 29 Oct 2025 14:15:06 +0100 Subject: [PATCH] Make test priovide sufficient context for understanding the default behavior, improve test by making assertions more specific --- .../LogTenancyBootstrapperTest.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/Bootstrappers/LogTenancyBootstrapperTest.php b/tests/Bootstrappers/LogTenancyBootstrapperTest.php index eb43e605..e1519cb1 100644 --- a/tests/Bootstrappers/LogTenancyBootstrapperTest.php +++ b/tests/Bootstrappers/LogTenancyBootstrapperTest.php @@ -66,7 +66,7 @@ test('storage path channels get tenant-specific paths by default', function () { } }); -test('all channels included in the log stack get processed', function () { +test('all channels included in the log stack get processed correctly', function () { config([ 'tenancy.bootstrappers' => [ FilesystemTenancyBootstrapper::class, @@ -79,16 +79,29 @@ test('all channels included in the log stack get processed', function () { ], ]); + $centralStoragePath = storage_path(); + $centralLogPath = $centralStoragePath . '/logs/laravel.log'; $originalSinglePath = config('logging.channels.single.path'); $originalDailyPath = config('logging.channels.daily.path'); + // By default, both paths are the same in the config. + // Note that in actual usage, the daily log file name is parsed differently from the path in the config, + // but the paths *in the config* are the same. + expect($centralLogPath) + ->toBe($centralStoragePath . '/logs/laravel.log') + ->toBe($originalSinglePath) + ->toBe($originalDailyPath); + $tenant = Tenant::create(); tenancy()->initialize($tenant); - // Both channels in the stack should be updated - expect(config('logging.channels.single.path'))->not()->toBe($originalSinglePath); - expect(config('logging.channels.daily.path'))->not()->toBe($originalDailyPath); + // Both channels in the stack are updated correctly + expect("{$centralStoragePath}/tenant{$tenant->id}/logs/laravel.log") + ->not()->toBe($originalSinglePath) + ->not()->toBe($originalDailyPath) + ->toBe(config('logging.channels.single.path')) + ->toBe(config('logging.channels.daily.path')); tenancy()->end();