Laravel - HTTP Tests - Making Requests
To make a request to your application, you may invoke the get
, post
, put
, patch
, or delete
methods within your test. These methods do not actually issue a "real" HTTP request to your application. Instead, the entire network request is simulated internally.
Instead of returning an Illuminate\Http\Response
instance, test request methods return an instance of Illuminate\Testing\TestResponse
, which provides a variety of helpful assertions that allow you to inspect your application's responses:
get('/');
$response->assertStatus(200);
}
}
In general, each of your tests should only make one request to your application. Unexpected behavior may occur if multiple requests are executed within a single test method.
For convenience, the CSRF middleware is automatically disabled when running tests.