FilterTestTrait
Filter Test Trait
Provides functionality for testing filters and their route associations.
Tags
Table of Contents
Properties
- $collection : RouteCollection|null
- The default App and discovered routes to check for filters.
- $filters : Filters|null
- The prepared Filters library.
- $filtersConfig : Filters|null
- The Filters configuration to use.
- $request : RequestInterface
- The active IncomingRequest or CLIRequest
- $response : ResponseInterface
- The active Response instance
- $doneFilterSetUp : bool
- Have the one-time classes been instantiated?
Methods
- assertFilter() : void
- Asserts that the given route at position uses the filter (by its alias).
- assertHasFilters() : mixed
- Asserts that the given route at position has at least one filter set.
- assertNotFilter() : mixed
- Asserts that the given route at position does not use the filter (by its alias).
- assertNotHasFilters() : mixed
- Asserts that the given route at position has no filters set.
- getFilterCaller() : Closure
- Returns a callable method for a filter position using the local HTTP instances.
- getFiltersForRoute() : array<int, string>
- Gets an array of filter aliases enabled for the given route at position.
- setUpFilterTestTrait() : void
- Initializes dependencies once.
Properties
$collection
The default App and discovered routes to check for filters.
protected
RouteCollection|null
$collection
$filters
The prepared Filters library.
protected
Filters|null
$filters
$filtersConfig
The Filters configuration to use.
protected
Filters|null
$filtersConfig
Extracted for access to aliases during Filters::discoverFilters().
$request
The active IncomingRequest or CLIRequest
protected
RequestInterface
$request
$response
The active Response instance
protected
ResponseInterface
$response
$doneFilterSetUp
Have the one-time classes been instantiated?
private
bool
$doneFilterSetUp
= false
Methods
assertFilter()
Asserts that the given route at position uses the filter (by its alias).
protected
assertFilter(string $route, string $position, string $alias) : void
Parameters
- $route : string
-
The route to test
- $position : string
-
"before" or "after"
- $alias : string
-
Alias for the anticipated filter
assertHasFilters()
Asserts that the given route at position has at least one filter set.
protected
assertHasFilters(string $route, string $position) : mixed
Parameters
- $route : string
-
The route to test
- $position : string
-
"before" or "after"
assertNotFilter()
Asserts that the given route at position does not use the filter (by its alias).
protected
assertNotFilter(string $route, string $position, string $alias) : mixed
Parameters
- $route : string
-
The route to test
- $position : string
-
"before" or "after"
- $alias : string
-
Alias for the anticipated filter
assertNotHasFilters()
Asserts that the given route at position has no filters set.
protected
assertNotHasFilters(string $route, string $position) : mixed
Parameters
- $route : string
-
The route to test
- $position : string
-
"before" or "after"
getFilterCaller()
Returns a callable method for a filter position using the local HTTP instances.
protected
getFilterCaller(FilterInterface|string $filter, string $position) : Closure
Parameters
- $filter : FilterInterface|string
-
The filter instance, class, or alias
- $position : string
-
"before" or "after"
Tags
Return values
ClosuregetFiltersForRoute()
Gets an array of filter aliases enabled for the given route at position.
protected
getFiltersForRoute(string $route, string $position) : array<int, string>
Parameters
- $route : string
-
The route to test
- $position : string
-
"before" or "after"
Return values
array<int, string> —The filter aliases
setUpFilterTestTrait()
Initializes dependencies once.
protected
setUpFilterTestTrait() : void