1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 11:14:04 +00:00

Misc test fixes (#44)

* Add suffix_storage_path test

* Get filesystem bootstrapper coverage to 100%

* Delete enabling DB bootstrapper in TestCase

* Complete most of test todos

* Complete last tests todo

* Fix docblock

* add todo

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
This commit is contained in:
Samuel Štancl 2024-04-06 19:17:34 +02:00 committed by GitHub
parent 489fbb9402
commit d9ca3cec38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 154 additions and 159 deletions

View file

@ -15,12 +15,18 @@ beforeEach(function () {
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
});
test('context is switched when tenancy is initialized', function () {
contextIsSwitchedWhenTenancyInitialized();
});
test('context is switched to tenant when initializing tenancy and reverted when ending tenancy', function () {
config(['tenancy.bootstrappers' => [
MyBootstrapper::class,
]]);
test('context is reverted when tenancy is ended', function () {
contextIsSwitchedWhenTenancyInitialized();
$tenant = Tenant::create([
'id' => 'acme',
]);
tenancy()->initialize($tenant);
expect(app('tenancy_initialized_for_tenant'))->toBe('acme');
tenancy()->end();
@ -95,22 +101,6 @@ test('central helper doesnt change tenancy state when called in central context'
expect(tenant())->toBeNull();
});
// todo@tests
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): void