Skip to content

Commit f3ea4db

Browse files
authored
Update testing.rst
1 parent 2238849 commit f3ea4db

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

testing.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,22 +306,26 @@ document::
306306
),
307307
'the "Content-Type" header is "application/json"' // optional message shown on failure
308308
);
309-
309+
//or
310+
$this->assertResponseHeaderSame('Content-Type', 'application/json', 'the "Content-Type" header is "application/json"');
310311
// asserts that the response content contains a string
311312
$this->assertStringContainsString('foo', $client->getResponse()->getContent());
312313
// ...or matches a regex
313314
$this->assertRegExp('/foo(bar)?/', $client->getResponse()->getContent());
314315

315316
// asserts that the response status code is 2xx
316317
$this->assertTrue($client->getResponse()->isSuccessful(), 'response status is 2xx');
318+
// ...or simply
319+
$this->assertResponseIsSuccessful('response status is 2xx');
317320
// asserts that the response status code is 404
318321
$this->assertTrue($client->getResponse()->isNotFound());
319322
// asserts a specific 200 status code
320323
$this->assertEquals(
321324
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK
322325
$client->getResponse()->getStatusCode()
323326
);
324-
327+
//...or simply
328+
$this->assertResponseStatusCodeSame(200);
325329
// asserts that the response is a redirect to /demo/contact
326330
$this->assertTrue(
327331
$client->getResponse()->isRedirect('/demo/contact')
@@ -330,7 +334,8 @@ document::
330334
);
331335
// ...or simply check that the response is a redirect to any URL
332336
$this->assertTrue($client->getResponse()->isRedirect());
333-
337+
// ...or simply
338+
$this->assertResponseRedirects();
334339
.. _testing-data-providers:
335340

336341
Testing against Different Sets of Data

0 commit comments

Comments
 (0)