From be031ad45ab84f8c8804a135ccbd55531d1d0a20 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 4 Apr 2024 18:04:45 +0200 Subject: [PATCH] Clear bootstrappers in TestCase --- tests/TenantDatabaseManagerTest.php | 34 ++++++++++++++--------------- tests/TestCase.php | 4 +--- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/tests/TenantDatabaseManagerTest.php b/tests/TenantDatabaseManagerTest.php index 5419c45d..9841fbec 100644 --- a/tests/TenantDatabaseManagerTest.php +++ b/tests/TenantDatabaseManagerTest.php @@ -2,30 +2,30 @@ declare(strict_types=1); -use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Str; use Illuminate\Support\Facades\DB; +use Stancl\JobPipeline\JobPipeline; +use Stancl\Tenancy\Tests\Etc\Tenant; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Schema; -use Illuminate\Support\Str; -use Stancl\JobPipeline\JobPipeline; -use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper; -use Stancl\Tenancy\Database\Contracts\StatefulTenantDatabaseManager; -use Stancl\Tenancy\Database\DatabaseManager; use Stancl\Tenancy\Events\TenancyEnded; -use Stancl\Tenancy\Events\TenancyInitialized; -use Stancl\Tenancy\Events\TenantCreated; -use Stancl\Tenancy\Database\Exceptions\TenantDatabaseAlreadyExistsException; use Stancl\Tenancy\Jobs\CreateDatabase; +use Stancl\Tenancy\Events\TenantCreated; +use Illuminate\Database\Schema\Blueprint; +use Stancl\Tenancy\Database\DatabaseManager; +use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Listeners\BootstrapTenancy; use Stancl\Tenancy\Listeners\RevertToCentralContext; -use Stancl\Tenancy\Database\TenantDatabaseManagers\MicrosoftSQLDatabaseManager; +use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper; +use Stancl\Tenancy\Database\Contracts\StatefulTenantDatabaseManager; use Stancl\Tenancy\Database\TenantDatabaseManagers\MySQLDatabaseManager; +use Stancl\Tenancy\Database\TenantDatabaseManagers\SQLiteDatabaseManager; +use Stancl\Tenancy\Database\TenantDatabaseManagers\PostgreSQLSchemaManager; +use Stancl\Tenancy\Database\Exceptions\TenantDatabaseAlreadyExistsException; +use Stancl\Tenancy\Database\TenantDatabaseManagers\PostgreSQLDatabaseManager; +use Stancl\Tenancy\Database\TenantDatabaseManagers\MicrosoftSQLDatabaseManager; use Stancl\Tenancy\Database\TenantDatabaseManagers\PermissionControlledMySQLDatabaseManager; use Stancl\Tenancy\Database\TenantDatabaseManagers\PermissionControlledMicrosoftSQLServerDatabaseManager; -use Stancl\Tenancy\Database\TenantDatabaseManagers\PostgreSQLDatabaseManager; -use Stancl\Tenancy\Database\TenantDatabaseManagers\PostgreSQLSchemaManager; -use Stancl\Tenancy\Database\TenantDatabaseManagers\SQLiteDatabaseManager; -use Stancl\Tenancy\Tests\Etc\Tenant; beforeEach(function () { SQLiteDatabaseManager::$path = null; @@ -96,7 +96,7 @@ test('dbs can be created when another driver is used for the central db', functi test('the tenant connection is fully removed', function () { config([ - 'tenancy.boostrappers' => [ + 'tenancy.bootstrappers' => [ DatabaseTenancyBootstrapper::class, ], ]); @@ -145,8 +145,8 @@ test('db name is prefixed with db path when sqlite is used', function () { test('schema manager uses schema to separate tenant dbs', function () { config([ - 'tenancy.database.managers.pgsql' => \Stancl\Tenancy\Database\TenantDatabaseManagers\PostgreSQLSchemaManager::class, - 'tenancy.boostrappers' => [ + 'tenancy.database.managers.pgsql' => PostgreSQLSchemaManager::class, + 'tenancy.bootstrappers' => [ DatabaseTenancyBootstrapper::class, ], ]); diff --git a/tests/TestCase.php b/tests/TestCase.php index 3ae67bdd..5d18cda4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -117,9 +117,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase '--force' => true, ], 'tenancy.central_domains' => ['localhost', '127.0.0.1'], - 'tenancy.bootstrappers' => [ - DatabaseTenancyBootstrapper::class, // todo@tests find why some tests are failing without this (especially 'the tenant connection is fully removed') - ], + 'tenancy.bootstrappers' => [], 'queue.connections.central' => [ 'driver' => 'sync', 'central' => true,