-
Notifications
You must be signed in to change notification settings - Fork 0
HTTP Tests
Gerard Rico Botella edited this page Nov 7, 2019
·
5 revisions
$response = $this->get('/uri');$response = $this->post('/uri');$this->loadFixtures([LoadUserData::class]);
$user = $this->getReference(LoadUserData::USER);
$response = $this->loginAs($user)->get('/uri');$crawler = $response->getCrawler();- assertOk
- assertNotFound
- assertForbidden
- assertUnauthorized
- assertRedirect
- assertSee
- assertSeeAll
- assertDontSee
- assertDontSeeAny
- assertExactJson
- assertViewIs
Assert that the response has a 200 status code
$response->assertOk();Assert that the response has a not found status code
$response->assertNotFound();Assert that the response has a forbidden status code
$response->assertForbidden();Assert that the response has a forbidden status code
$response->assertUnauthorized();Assert that the response is a redirect. If a redirect url is provided assert that the redirect location match that url.
$response->assertRedirect();
$response->assertRedirect('/your-url');Assert that the given string is contained within the response
$response->assertSee('Assert that response content has this text');Assert that the given strings are contained within the response
$response->assertSeeAll(['First needle', 'Second needle']);Assert that the given string is not contained within the response
$response->assertDontSee('Assert that response content does not have this text');Assert that the given strings are not contained within the response
$response->assertDontSeeAny(['First needle', 'Second needle']);Assert that the response contains an exact match of the given JSON data
$response->assertExactJson(['id' => 30, 'name' => 'dummy']);Assert that the given view was returned by the route
$response->assertViewIs('expected_view.html.twig);