| Fully Qualified Name: | CodeIgniter\Test\ControllerTester |
ControllerTester Trait
Provides features that make testing controllers simple and fluent.
Example:
$this->withRequest($request)
->withResponse($response)
->withURI($uri)
->withBody($body)
->controller('App\Controllers\Home')
->run('methodName');
| Name | Description | Defined By |
|---|---|---|
| controller() | Loads the specified controller, and generates any needed dependencies. | ControllerTester |
| execute() | Runs the specified method on the controller and returns the results. | ControllerTester |
| withBody() | Set the method's body, with method chaining. | ControllerTester |
| withConfig() | Set controller's config, with method chaining. | ControllerTester |
| withLogger() | Set controller's logger, with method chaining. | ControllerTester |
| withRequest() | Set controller's request, with method chaining. | ControllerTester |
| withResponse() | Set controller's response, with method chaining. | ControllerTester |
| withUri() | Set the controller's URI, with method chaining. | ControllerTester |
Loads the specified controller, and generates any needed dependencies.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: mixed
Runs the specified method on the controller and returns the results.
| Parameter Name | Type | Description |
|---|---|---|
| $method | string | |
| $params | array |
Returns: \CodeIgniter\Test\ControllerResponse|\InvalidArgumentException
Set the method's body, with method chaining.
| Parameter Name | Type | Description |
|---|---|---|
| $body | mixed |
Returns: mixed
Set controller's config, with method chaining.
| Parameter Name | Type | Description |
|---|---|---|
| $appConfig | mixed |
Returns: mixed
Set controller's logger, with method chaining.
| Parameter Name | Type | Description |
|---|---|---|
| $logger | mixed |
Returns: mixed
Set controller's request, with method chaining.
| Parameter Name | Type | Description |
|---|---|---|
| $request | mixed |
Returns: mixed
Set controller's response, with method chaining.
| Parameter Name | Type | Description |
|---|---|---|
| $response | mixed |
Returns: mixed
Set the controller's URI, with method chaining.
| Parameter Name | Type | Description |
|---|---|---|
| $uri | string |
Returns: mixed