\CodeIgniter\TestControllerTester

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');

Summary

Methods
Properties
Constants
controller()
execute()
withConfig()
withRequest()
withResponse()
withLogger()
withUri()
withBody()
No public properties found
No constants found
No protected methods found
$appConfig
$request
$response
$logger
$controller
$uri
$body
N/A
No private methods found
No private properties found
N/A

Properties

$appConfig

$appConfig : \CodeIgniter\Test\BaseConfig

Controller configuration.

Type

\CodeIgniter\Test\BaseConfig

$request

$request : \CodeIgniter\Test\Request

Request.

Type

\CodeIgniter\Test\Request

$logger

$logger : \CodeIgniter\Test\LoggerInterface

Message logger.

Type

\CodeIgniter\Test\LoggerInterface

$controller

$controller : \CodeIgniter\Test\Controller

Initialized controller.

Type

\CodeIgniter\Test\Controller

$uri

$uri : string

URI of this request.

Type

string

$body

$body : string

Request or response body.

Type

string

Methods

controller()

controller(string  $name) : mixed

Loads the specified controller, and generates any needed dependencies.

Parameters

string $name

Returns

mixed

execute()

execute(string  $method, array  $params) : \CodeIgniter\Test\ControllerResponse|\InvalidArgumentException

Runs the specified method on the controller and returns the results.

Parameters

string $method
array $params

Returns

\CodeIgniter\Test\ControllerResponse|\InvalidArgumentException

withConfig()

withConfig(mixed  $appConfig) : mixed

Set controller's config, with method chaining.

Parameters

mixed $appConfig

Returns

mixed

withRequest()

withRequest(mixed  $request) : mixed

Set controller's request, with method chaining.

Parameters

mixed $request

Returns

mixed

withResponse()

withResponse(mixed  $response) : mixed

Set controller's response, with method chaining.

Parameters

mixed $response

Returns

mixed

withLogger()

withLogger(mixed  $logger) : mixed

Set controller's logger, with method chaining.

Parameters

mixed $logger

Returns

mixed

withUri()

withUri(string  $uri) : mixed

Set the controller's URI, with method chaining.

Parameters

string $uri

Returns

mixed

withBody()

withBody(mixed  $body) : mixed

Set the method's body, with method chaining.

Parameters

mixed $body

Returns

mixed