From 0f921c1362f891a164685852003caef3fecb7d83 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 10 May 2023 12:27:28 +0200 Subject: [PATCH] Fix Postgres test --- tests/PostgresTest.php | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/PostgresTest.php b/tests/PostgresTest.php index d455aeda..5f7d1aa3 100644 --- a/tests/PostgresTest.php +++ b/tests/PostgresTest.php @@ -76,11 +76,6 @@ beforeEach(function () { }); }); -afterEach(function () { - Schema::dropIfExists('uuid_comments'); - Schema::dropIfExists('uuid_posts'); -}); - test('postgres user can get created using the job', function() { $tenant = Tenant::create(); $name = $tenant->getTenantKey(); @@ -203,7 +198,7 @@ trait UsesUuidAsPrimaryKey class UuidPost extends Model { - use BelongsToTenant; + use UsesUuidAsPrimaryKey, BelongsToTenant; public $incrementing = false; public $table = 'uuid_posts'; @@ -221,20 +216,10 @@ class UuidPost extends Model } } -class UuidScopedComment extends UuidComment -{ - use BelongsToPrimaryModel; - - protected $guarded = []; - - public function getRelationshipToPrimaryModel(): string - { - return 'uuid_post'; - } -} - class UuidComment extends Model { + use UsesUuidAsPrimaryKey; + protected $guarded = []; protected $keyType = 'string'; @@ -246,3 +231,15 @@ class UuidComment extends Model return $this->belongsTo(UuidPost::class); } } + +class UuidScopedComment extends UuidComment +{ + use UsesUuidAsPrimaryKey, BelongsToPrimaryModel; + + protected $guarded = []; + + public function getRelationshipToPrimaryModel(): string + { + return 'uuid_post'; + } +}