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

Add and test excluding models from discovery

This commit is contained in:
lukinovec 2023-07-20 13:43:10 +02:00
parent a664860d63
commit 2a5683122e
2 changed files with 15 additions and 3 deletions

View file

@ -249,9 +249,19 @@ test('model discovery gets the models correctly', function() {
// Check that the Post and ScopedComment models are found in the directory
$expectedModels = [Post::class, ScopedComment::class];
$foundModels = array_filter(tenancy()->getModels(), fn (Model $model) => in_array($model::class, $expectedModels));
$foundModels = fn () => collect(tenancy()->getModels())->filter(fn (Model $model) => in_array($model::class, $expectedModels));
expect($foundModels)->toHaveCount(count($expectedModels));
expect($foundModels()->map(fn (Model $model) => $model::class)->values())
->toHaveCount(count($expectedModels))
->toContain(...$expectedModels);
$expectedModels = [Post::class];
$excludedModels = tenancy()::$modelsExcludedFromDiscovery = [ScopedComment::class];
expect($foundModels()->map(fn (Model $model) => $model::class)->values())
->toHaveCount(count($expectedModels))
->toContain(...$expectedModels)
->not()->toContain(...$excludedModels);
});
trait UsesUuidAsPrimaryKey