Class MiddlewareDispatcher
Dispatches a request capturing the response for integration testing purposes into the Cake\Http stack.
Property Summary
-
$_class protected
string
The application class name
-
$_constructorArgs protected
array
Constructor arguments for your application class.
-
$_test protected
Cake\TestSuite\TestCase
The test case being run.
-
$app protected
Cake\Core\HttpApplicationInterface
The application that is being dispatched.
Method Summary
-
__construct() public
Constructor
-
_createRequest() protected
Create a PSR7 request from the request spec.
-
execute() public
Run a request and get the response.
-
resolveRoute() protected
Convert a URL array into a string URL via routing.
-
resolveUrl() public
Resolve the provided URL into a string.
Method Detail
__construct() ¶ public
__construct(Cake\TestSuite\TestCase $test, string|null $class = null, array|null $constructorArgs = null)
Constructor
Parameters
-
Cake\TestSuite\TestCase
$test The test case to run.
-
string|null
$class optional The application class name. Defaults to App\Application.
-
array|null
$constructorArgs optional The constructor arguments for your application class. Defaults to
['./config']
Throws
LogicException
If it cannot load class for use in integration testing.
_createRequest() ¶ protected
_createRequest(array $spec): Cake\Http\ServerRequest
Create a PSR7 request from the request spec.
Parameters
-
array
$spec The request spec.
Returns
Cake\Http\ServerRequest
execute() ¶ public
execute(array $requestSpec): Psr\Http\Message\ResponseInterface
Run a request and get the response.
Parameters
-
array
$requestSpec The request spec to execute.
Returns
Psr\Http\Message\ResponseInterface
Throws
LogicException
resolveRoute() ¶ protected
resolveRoute(array $url): string
Convert a URL array into a string URL via routing.
Parameters
-
array
$url The url to resolve
Returns
string
resolveUrl() ¶ public
resolveUrl(array|string $url): string
Resolve the provided URL into a string.
Parameters
-
array|string
$url The URL array/string to resolve.
Returns
string