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:
parent
a664860d63
commit
2a5683122e
2 changed files with 15 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue