1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 21:34:03 +00:00
This commit is contained in:
Abrar Ahmad 2022-11-04 12:08:35 +05:00
parent 77c5ae1f32
commit f13460d91f
3 changed files with 46 additions and 2 deletions

View file

@ -763,6 +763,25 @@ function creatingResourceInTenantDatabaseCreatesAndMapInCentralDatabase()
expect(ResourceUser::first()->role)->toBe('commenter');
}
test('resources are synced only when sync is enabled', function () {
[$tenant1, $tenant2] = createTenantsAndRunMigrations();
tenancy()->initialize($tenant1);
TenantUserWithDisabledSync::create([
'global_id' => 'absd',
'name' => 'John Doe',
'email' => 'john@localhost',
'password' => 'password',
'role' => 'commenter',
]);
tenancy()->end();
expect(CentralUser::all())->toHaveCount(0);
})->group('current');
/**
* Create two tenants and run migrations for those tenants.
*/
@ -979,3 +998,19 @@ class ResourceUserProvidingMixture extends ResourceUser
];
}
}
class CentralUserWithDisabledSync extends CentralUser
{
public function shouldSync(): bool
{
return false;
}
}
class TenantUserWithDisabledSync extends CentralUser
{
public function shouldSync(): bool
{
return false;
}
}