1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 22:24:03 +00:00

resolve reviews

This commit is contained in:
Abrar Ahmad 2022-07-01 11:37:31 +05:00
parent 4048b523e3
commit c515bbfaa1
5 changed files with 56 additions and 80 deletions

View file

@ -15,27 +15,12 @@ beforeEach(function () {
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
});
function contextISSwitchedWhenTenancyInitialized()
{
config(['tenancy.bootstrappers' => [
MyBootstrapper::class,
]]);
$tenant = Tenant::create([
'id' => 'acme',
]);
tenancy()->initialize($tenant);
expect(app('tenancy_initialized_for_tenant'))->toBe('acme');
}
test('context is switched when tenancy is initialized', function () {
contextISSwitchedWhenTenancyInitialized();
contextIsSwitchedWhenTenancyInitialized();
});
test('context is reverted when tenancy is ended', function () {
contextISSwitchedWhenTenancyInitialized();
contextIsSwitchedWhenTenancyInitialized();
tenancy()->end();
@ -104,6 +89,21 @@ test('central helper doesnt change tenancy state when called in central context'
expect(tenant())->toBeNull();
});
function contextIsSwitchedWhenTenancyInitialized()
{
config(['tenancy.bootstrappers' => [
MyBootstrapper::class,
]]);
$tenant = Tenant::create([
'id' => 'acme',
]);
tenancy()->initialize($tenant);
expect(app('tenancy_initialized_for_tenant'))->toBe('acme');
}
class MyBootstrapper implements TenancyBootstrapper
{
public function bootstrap(\Stancl\Tenancy\Contracts\Tenant $tenant)