1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 19:34:04 +00:00

Update ResourceSyncingTest.php

This commit is contained in:
Abrar Ahmad 2022-08-29 13:16:00 +05:00
parent b437f64e30
commit 62c9516ec1

View file

@ -236,22 +236,6 @@ test('creating the resource in central database creates it in tenant database as
});
test('creating the resource in central database creates it in tenant database with default attributes values', function () {
// override method in CentralUser class to return attribute default values
class CentralUserWithDefaultValues extends CentralUser {
public function getResourceCreationAttributes(): array
{
// Attributes default values when creating resources from central to tenant model
return
[
'global_id' => 'abc-123',
'name' => 'John',
'password' => 'password',
'email' => 'john@demo',
'role' => 'admin',
];
}
}
$centralUser = CentralUserWithDefaultValues::create([
'global_id' => 'acme',
'name' => 'John Doe',
@ -282,22 +266,6 @@ test('creating the resource in central database creates it in tenant database wi
});
test('creating the resource in central database creates it in tenant database with attributes names', function () {
// override method in CentralUser class to return attribute names
class CentralUserWithAttributeNames extends CentralUser {
public function getResourceCreationAttributes(): array
{
// Attributes used when creating resources from central to tenant DB
return
[
'global_id',
'name',
'password',
'email',
'role',
];
}
}
// migrate extra column "foo" in central DB
pest()->artisan('migrate', [
'--path' => __DIR__ . '/Etc/synced_resource_migrations/users_extra',
@ -875,3 +843,36 @@ class ResourceUserWithAttributeNames extends ResourceUser {
}
// override method in CentralUser class to return attribute default values
class CentralUserWithDefaultValues extends CentralUser {
public function getResourceCreationAttributes(): array
{
// Attributes default values when creating resources from central to tenant model
return
[
'global_id' => 'abc-123',
'name' => 'John',
'password' => 'password',
'email' => 'john@demo',
'role' => 'admin',
];
}
}
// override method in CentralUser class to return attribute names
class CentralUserWithAttributeNames extends CentralUser {
public function getResourceCreationAttributes(): array
{
// Attributes used when creating resources from central to tenant DB
return
[
'global_id',
'name',
'password',
'email',
'role',
];
}
}