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');
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 42
__construct(string $content, int $status = 200)
Constructs a new TestResponse instance.
at line 54
void
assertDontSee(string $text)
Asserts that the given text is not present in the response content.
at line 70
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 87
void
assertSee(string $text)
Asserts that the response content contains the given text.
at line 102
void
assertStatus(int $expected)
Asserts that the response status matches the expected value.
at line 116
string
getContent()
Returns the response content.