mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 14:34:04 +00:00
Bootstrap features manually in tests
This commit is contained in:
parent
3e6dd646ae
commit
91f8adb698
3 changed files with 23 additions and 17 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue