mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:54:03 +00:00
use unset approach
This commit is contained in:
parent
53d5ffb3b4
commit
86469dd357
1 changed files with 10 additions and 4 deletions
|
|
@ -74,8 +74,9 @@ test('resource syncing works using a single pivot table for multiple models when
|
||||||
|
|
||||||
// Assert User resource is synced
|
// Assert User resource is synced
|
||||||
$tenant1->run(function () use ($centralUser) {
|
$tenant1->run(function () use ($centralUser) {
|
||||||
$tenantUser = TenantUserUsingPolymorphic::first()->only(['name', 'email', 'password', 'role']);
|
$tenantUser = TenantUserUsingPolymorphic::first()->toArray();
|
||||||
$centralUser = $centralUser->only(['name', 'email', 'password', 'role']);
|
$centralUser = $centralUser->withoutRelations()->toArray();
|
||||||
|
unset($centralUser['id'], $tenantUser['id']);
|
||||||
|
|
||||||
expect($tenantUser)->toBe($centralUser);
|
expect($tenantUser)->toBe($centralUser);
|
||||||
});
|
});
|
||||||
|
|
@ -122,8 +123,13 @@ test('resource syncing works using a single pivot table for multiple models when
|
||||||
tenancy()->end();
|
tenancy()->end();
|
||||||
|
|
||||||
// Assert User resource is synced
|
// Assert User resource is synced
|
||||||
$centralUser = CentralUserUsingPolymorphic::first()->only(['name', 'email', 'password', 'role']);
|
$centralUser = CentralUserUsingPolymorphic::first()->toArray();
|
||||||
$tenantUser = $tenantUser->only(['name', 'email', 'password', 'role']);
|
$tenantUser = $tenantUser->toArray();
|
||||||
|
unset($centralUser['id'], $tenantUser['id']);
|
||||||
|
|
||||||
|
// reorder global_id in $centralUser to put it at the last position so we can match the exact array
|
||||||
|
$centralUser['global_id'] = array_shift($centralUser);
|
||||||
|
|
||||||
expect($tenantUser)->toBe($centralUser);
|
expect($tenantUser)->toBe($centralUser);
|
||||||
|
|
||||||
$tenant2 = ResourceTenantUsingPolymorphic::create(['id' => 't2']);
|
$tenant2 = ResourceTenantUsingPolymorphic::create(['id' => 't2']);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue