From 1ce18d27594c097ffd1c67eb80b45c063d1e64d9 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 15 Jun 2023 11:45:38 +0200 Subject: [PATCH] Add basic model discovery test --- tests/PostgresRLSTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/PostgresRLSTest.php b/tests/PostgresRLSTest.php index 1f2fcebc..f5f2f355 100644 --- a/tests/PostgresRLSTest.php +++ b/tests/PostgresRLSTest.php @@ -229,6 +229,18 @@ test('users created by CreatePostgresUserForTenant are only granted the permissi ->not()->toContain('DELETE'); }); +test('model discovery gets the models correctly', function() { + // 'tenancy.rls.model_directories' is set to [__DIR__ . '/Etc'] in beforeEach + // Check that the Post and ScopedComment models are found in the directory + $expectedModels = [Post::class, ScopedComment::class]; + + $foundModels = tenancy()->getModels()->where(function (Model $model) use ($expectedModels) { + return in_array($model::class, $expectedModels); + }); + + expect($foundModels)->toHaveCount(count($expectedModels)); +}); + trait UsesUuidAsPrimaryKey { use HasUuids;