TestResponse
class TestResponse
A simplified test response wrapper that mimics HTTP-style responses for use in feature tests.
This class is used to encapsulate content and status from simulated controller executions, and provides assertion methods to verify test outcomes such as HTTP status or content presence.
Example usage in a test: $response = $this->get('/'); $response->assertStatus(200); $response->assertSee('Welcome');
Properties
| protected string | $content | The response body content. |
|
| protected int | $status | The simulated HTTP status code. |
Methods
Constructs a new TestResponse instance.
Asserts that the given text is not present in the response content.
Asserts that the response content is a valid JSON string and that it contains the specified keys and values.
Asserts that the response content contains the given text.
Asserts that the response status matches the expected value.
Returns the response content.
Details
at line 41
__construct(string $content, int $status = 200)
Constructs a new TestResponse instance.
at line 53
void
assertDontSee(string $text)
Asserts that the given text is not present in the response content.
at line 69
void
assertJson(array $expected)
Asserts that the response content is a valid JSON string and that it contains the specified keys and values.
at line 86
void
assertSee(string $text)
Asserts that the response content contains the given text.
at line 101
void
assertStatus(int $expected)
Asserts that the response status matches the expected value.
at line 115
string
getContent()
Returns the response content.