Skip to content

Commit 13ff783

Browse files
committed
minor #13051 [Testing] Use a better example for Symfony asserts (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch (closes #13051). Discussion ---------- [Testing] Use a better example for Symfony asserts Fixes #13036. Commits ------- bed8a5e [Testing] Use a better example for Symfony asserts
2 parents 1514ffb + bed8a5e commit 13ff783

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

testing/functional_tests_assertions.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ When doing functional tests, sometimes you need to make complex assertions in
1313
order to check whether the ``Request``, the ``Response`` or the ``Crawler``
1414
contain the expected information to make your test succeed.
1515

16-
Here is an example with plain PHPUnit::
16+
The following example uses plain PHPUnit to assert that the response redirects
17+
to a certain URL::
1718

18-
$this->assertGreaterThan(
19-
0,
20-
$crawler->filter('html:contains("Hello World")')->count()
21-
);
19+
$this->assertSame(301, $client->getResponse()->getStatusCode());
20+
$this->assertSame('https://example.com', $client->getResponse()->headers->get('Location'));
2221

23-
Now here is the example with the assertions specific to Symfony::
22+
This is the same example using the assertions provided by Symfony::
2423

25-
$this->assertSelectorTextContains('html', 'Hello World');
24+
$this->assertResponseRedirects('https://example.com', 301);
2625

2726
.. note::
2827

@@ -70,9 +69,9 @@ Crawler
7069

7170
- ``assertSelectorExists()``
7271
- ``assertSelectorNotExists()``
73-
- ``assertSelectorTextContains()``
74-
- ``assertSelectorTextSame()``
75-
- ``assertSelectorTextNotContains()``
72+
- ``assertSelectorTextContains()`` (note: it only checks the first selector occurrence)
73+
- ``assertSelectorTextSame()`` (note: it only checks the first selector occurrence)
74+
- ``assertSelectorTextNotContains()`` (note: it only checks the first selector occurrence)
7675
- ``assertPageTitleSame()``
7776
- ``assertPageTitleContains()``
7877
- ``assertInputValueSame()``

0 commit comments

Comments
 (0)