From 724ed5a502ce6d89e1afac0cd1667e04aef33b65 Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Wed, 10 Aug 2022 13:03:17 +0500 Subject: [PATCH] Revert "improve comments, move method to `SyncMaster` interface" This reverts commit 5ddd50deb9f5aa2ad0ebadec5bd5afcbf7e1257e. --- src/Contracts/SyncMaster.php | 2 -- src/Contracts/Syncable.php | 2 ++ tests/ResourceSyncingTest.php | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Contracts/SyncMaster.php b/src/Contracts/SyncMaster.php index ffd803e6..e1b34149 100644 --- a/src/Contracts/SyncMaster.php +++ b/src/Contracts/SyncMaster.php @@ -15,6 +15,4 @@ interface SyncMaster extends Syncable public function tenants(): BelongsToMany; public function getTenantModelName(): string; - - public function getCreateAttributeNames(): array; } diff --git a/src/Contracts/Syncable.php b/src/Contracts/Syncable.php index 1f6e36e7..fa707719 100644 --- a/src/Contracts/Syncable.php +++ b/src/Contracts/Syncable.php @@ -15,4 +15,6 @@ interface Syncable public function getSyncedAttributeNames(): array; public function triggerSyncEvent(); + + public function getCreateAttributeNames(): array; } diff --git a/tests/ResourceSyncingTest.php b/tests/ResourceSyncingTest.php index c07e14b4..0213a864 100644 --- a/tests/ResourceSyncingTest.php +++ b/tests/ResourceSyncingTest.php @@ -150,9 +150,8 @@ test('creating the resource in tenant database creates it in central database an tenancy()->end(); - // Assert central user was created without `code` property + // assert user was created expect(CentralUser::first()->global_id)->toBe('acme'); - expect(CentralUser::first()->code)->toBeNull(); }); test('creating the resource in tenant database creates it in central database and creates the mapping', function () { @@ -630,7 +629,7 @@ class CentralUser extends Model implements SyncMaster public function getCreateAttributeNames(): array { - // Attributes used when creating resources from central to tenant DB + // attributes should be used when syncing resources from central to tenant DB return [ 'global_id', 'name', @@ -674,4 +673,16 @@ class ResourceUser extends Model implements Syncable 'email', ]; } + + public function getCreateAttributeNames(): array + { + // attributes should be used when syncing resources from tenant to central DB + return [ + 'global_id', + 'name', + 'password', + 'email', + 'role' + ]; + } }