ApplicationTestCase
abstract class ApplicationTestCase extends TestCase
Abstract class for test cases.
Properties
| static array | $controllerOutput | The controller output. |
Methods
Assert that a record exists in the specified database table with the given conditions.
Assert that no record exists in the specified database table with the given conditions.
Asserts that a property exists on the View object captured via controllerOutput().
Simulates a controller action based on URL-style input and captures its output.
Simulates an HTTP GET request to a given URI by resolving and executing the corresponding controller and action, capturing the output.
Create a mock file for actions that require file input in form submissions.
Simulates a POST request by setting $_POST data and executing the specified controller and action. Returns a TestResponse with the output and status.
Simulates a DELETE request to a specified URI. This sets the request method to DELETE and runs the matching controller action.
Implements setUp function from TestCase class.
Details
at line 36
void
assertDatabaseHas(string $table, array $data, string $message = '')
Assert that a record exists in the specified database table with the given conditions.
This method builds a SQL WHERE clause from the provided key-value array and checks whether a matching row exists. It fails the test if no such row is found.
at line 74
void
assertDatabaseMissing(string $table, array $data, string $message = '')
Assert that no record exists in the specified database table with the given conditions.
This method builds a SQL WHERE clause from the provided key-value array and verifies that no matching row exists. It fails the test if such a row is found.
at line 106
void
assertViewContains(string $property, mixed $expectedValue = null)
Asserts that a property exists on the View object captured via controllerOutput().
Optionally asserts that the value matches.
at line 132
protected string
controllerOutput(string $controllerSlug, string $actionSlug, array $urlSegments = [])
Simulates a controller action based on URL-style input and captures its output.
at line 175
protected TestResponse
get(string $uri)
Simulates an HTTP GET request to a given URI by resolving and executing the corresponding controller and action, capturing the output.
Supports URI segments in the form of /controller/action/param1/param2, and maps them to a controller class and action method with optional parameters passed positionally.
Example:
- get('/') → HomeController::indexAction()
- get('/products/show/3') → ProductsController::showAction(3)
at line 201
protected void
mockFile(string $files)
Create a mock file for actions that require file input in form submissions.
at line 219
protected TestResponse
post(string $uri, array $data = [])
Simulates a POST request by setting $_POST data and executing the specified controller and action. Returns a TestResponse with the output and status.
at line 255
protected TestResponse
put(string $uri, array $data = [])
Simulates a DELETE request to a specified URI. This sets the request method to DELETE and runs the matching controller action.
at line 288
protected void
setUp()
Implements setUp function from TestCase class.