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

Add basic model discovery test

This commit is contained in:
lukinovec 2023-06-15 11:45:38 +02:00
parent 5cb3b5f4c1
commit 1ce18d2759

View file

@ -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;