diff --git a/tests/Features/TenantConfigTest.php b/tests/Features/TenantConfigTest.php index 5c12c5f0..c6e135f4 100644 --- a/tests/Features/TenantConfigTest.php +++ b/tests/Features/TenantConfigTest.php @@ -2,13 +2,23 @@ declare(strict_types=1); +use Stancl\Tenancy\Tests\Etc\Tenant; use Illuminate\Support\Facades\Event; use Stancl\Tenancy\Events\TenancyEnded; -use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Features\TenantConfig; +use Stancl\Tenancy\TenancyServiceProvider; +use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Listeners\BootstrapTenancy; use Stancl\Tenancy\Listeners\RevertToCentralContext; -use Stancl\Tenancy\Tests\Etc\Tenant; + +beforeEach(function() { + config([ + 'tenancy.features' => [TenantConfig::class], + 'tenancy.bootstrappers' => [], + ]); + + TenancyServiceProvider::bootstrapFeatures(); +}); afterEach(function () { TenantConfig::$storageToConfigMap = []; @@ -16,10 +26,7 @@ afterEach(function () { test('nested tenant values are merged', function () { expect(config('whitelabel.theme'))->toBeNull(); - config([ - 'tenancy.features' => [TenantConfig::class], - 'tenancy.bootstrappers' => [], - ]); + Event::listen(TenancyInitialized::class, BootstrapTenancy::class); Event::listen(TenancyEnded::class, RevertToCentralContext::class); @@ -37,11 +44,8 @@ test('nested tenant values are merged', function () { }); test('config is merged and removed', function () { - expect(config('services.paypal'))->toBe(null); - config([ - 'tenancy.features' => [TenantConfig::class], - 'tenancy.bootstrappers' => [], - ]); + expect(config('services.paypal'))->toBeNull(); + Event::listen(TenancyInitialized::class, BootstrapTenancy::class); Event::listen(TenancyEnded::class, RevertToCentralContext::class); @@ -64,13 +68,9 @@ test('config is merged and removed', function () { 'private' => null, ], config('services.paypal')); }); - test('the value can be set to multiple config keys', function () { - expect(config('services.paypal'))->toBe(null); - config([ - 'tenancy.features' => [TenantConfig::class], - 'tenancy.bootstrappers' => [], - ]); + expect(config('services.paypal'))->toBeNull(); + Event::listen(TenancyInitialized::class, BootstrapTenancy::class); Event::listen(TenancyEnded::class, RevertToCentralContext::class); diff --git a/tests/Features/ViteBundlerTest.php b/tests/Features/ViteBundlerTest.php index 0d4c9069..26e646db 100644 --- a/tests/Features/ViteBundlerTest.php +++ b/tests/Features/ViteBundlerTest.php @@ -6,6 +6,7 @@ use Illuminate\Foundation\Vite; use Stancl\Tenancy\Tests\Etc\Tenant; use Stancl\Tenancy\Vite as StanclVite; use Stancl\Tenancy\Features\ViteBundler; +use Stancl\Tenancy\TenancyServiceProvider; test('vite helper uses our custom class', function() { $vite = app(Vite::class); @@ -17,6 +18,8 @@ test('vite helper uses our custom class', function() { 'tenancy.features' => [ViteBundler::class], ]); + TenancyServiceProvider::bootstrapFeatures(); + $tenant = Tenant::create(); tenancy()->initialize($tenant); diff --git a/tests/TenantUserImpersonationTest.php b/tests/TenantUserImpersonationTest.php index 1e72c604..7deaadb4 100644 --- a/tests/TenantUserImpersonationTest.php +++ b/tests/TenantUserImpersonationTest.php @@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Route; use Stancl\Tenancy\Events\TenancyEnded; use Stancl\Tenancy\Jobs\CreateDatabase; use Stancl\Tenancy\Events\TenantCreated; +use Stancl\Tenancy\TenancyServiceProvider; use Stancl\Tenancy\Events\TenancyInitialized; use Stancl\Tenancy\Features\UserImpersonation; use Stancl\Tenancy\Listeners\BootstrapTenancy; @@ -41,6 +42,8 @@ beforeEach(function () { ], ]); + TenancyServiceProvider::bootstrapFeatures(); + Event::listen( TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {