AssertsPolicyQueryConsistency
trait AssertsPolicyQueryConsistency
Assertions for verifying that a policy's query-aware methods (Scope, Select) produce the same results as the per-instance PHP method.
Use these in tests to catch drift between a policy's edit() method and its editScope()/editSelect() counterparts.
Methods
Assert that a policy's *Scope method filters to the same rows as calling Gate::allows() on each model individually.
Assert that a policy's *Select method produces the same boolean per row as calling Gate::allows() on each model individually.
Details
at line 27
protected void
assertScopeMatchesPolicy(string $ability, Builder $baseQuery, iterable $models, mixed $user)
Assert that a policy's *Scope method filters to the same rows as calling Gate::allows() on each model individually.
at line 73
protected void
assertSelectMatchesPolicy(string $ability, Builder $baseQuery, iterable $models, mixed $user, string|null $columnName = null)
Assert that a policy's *Select method produces the same boolean per row as calling Gate::allows() on each model individually.