From 26c161a9407e1b71e3bea5ca4d63ed008591d5eb Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 1 May 2026 15:16:54 +0200 Subject: [PATCH] Add regression test for makeConnectionConfig not working correctly with custom $path In makeConnectionConfig, changing the $this->getPath($databaseName) line back to `$baseConfig['database'] = database_path($databaseName);` will make the added test fail. --- tests/TenantDatabaseManagerTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/TenantDatabaseManagerTest.php b/tests/TenantDatabaseManagerTest.php index caa9109e..f29f9a63 100644 --- a/tests/TenantDatabaseManagerTest.php +++ b/tests/TenantDatabaseManagerTest.php @@ -644,6 +644,23 @@ test('sqlite database manager recognizes inmemory databases correctly', function expect($manager->isInMemory('_tenancy_inmemory_123?mode=memory&cache=shared'))->toBeFalse(); }); +test('sqlite database manager respects the configured path while making the database config', function () { + config()->set([ + 'tenancy.database.template_tenant_connection' => 'sqlite', + ]); + + $tenant = Tenant::make([ + 'tenancy_db_name' => 'tenant.sqlite', + ]); + + // SQLiteDatabaseManager::$path is null, the database path is built using database_path() + expect($tenant->database()->connection()['database'])->toBe(database_path('tenant.sqlite')); + + SQLiteDatabaseManager::$path = $customPath = '/custom/path/'; + + expect($tenant->database()->connection()['database'])->toBe($customPath . 'tenant.sqlite'); +}); + // Datasets dataset('database_managers', [ ['mysql', MySQLDatabaseManager::class],