Skip to content

Commit d13c608

Browse files
committed
minor #13886 Update testing.rst (zairigimad)
This PR was submitted for the 5.0 branch but it was merged into the 4.4 branch instead. Discussion ---------- Update testing.rst <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 431c2e8 Update testing.rst
2 parents ba962c3 + 431c2e8 commit d13c608

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
@@ -310,22 +310,26 @@ document::
310310
),
311311
'the "Content-Type" header is "application/json"' // optional message shown on failure
312312
);
313-
313+
//or
314+
$this->assertResponseHeaderSame('Content-Type', 'application/json', 'the "Content-Type" header is "application/json"');
314315
// asserts that the response content contains a string
315316
$this->assertContains('foo', $client->getResponse()->getContent());
316317
// ...or matches a regex
317318
$this->assertRegExp('/foo(bar)?/', $client->getResponse()->getContent());
318319

319320
// asserts that the response status code is 2xx
320321
$this->assertTrue($client->getResponse()->isSuccessful(), 'response status is 2xx');
322+
// ...or simply
323+
$this->assertResponseIsSuccessful('response status is 2xx');
321324
// asserts that the response status code is 404
322325
$this->assertTrue($client->getResponse()->isNotFound());
323326
// asserts a specific 200 status code
324327
$this->assertEquals(
325328
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK
326329
$client->getResponse()->getStatusCode()
327330
);
328-
331+
//...or simply
332+
$this->assertResponseStatusCodeSame(200);
329333
// asserts that the response is a redirect to /demo/contact
330334
$this->assertTrue(
331335
$client->getResponse()->isRedirect('/demo/contact')
@@ -334,7 +338,8 @@ document::
334338
);
335339
// ...or simply check that the response is a redirect to any URL
336340
$this->assertTrue($client->getResponse()->isRedirect());
337-
341+
// ...or simply
342+
$this->assertResponseRedirects();
338343
.. _testing-data-providers:
339344

340345
Testing against Different Sets of Data

0 commit comments

Comments
 (0)