8000 Merge branch '4.4' into 5.0 · symfony/symfony-docs@b676c63 · GitHub
[go: up one dir, main page]

Skip to content

Commit b676c63

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: [Testing] Use a better example for Symfony asserts
2 parents 7d621eb + 13ff783 commit b676c63

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
@@ -8,16 +8,15 @@ When doing functional tests, sometimes you need to make complex assertions in
88
order to check whether the ``Request``, the ``Response`` or the ``Crawler``
99
contain the expected information to make your test succeed.
1010

11-
Here is an example with plain PHPUnit::
11+
The following example uses plain PHPUnit to assert that the response redirects
12+
to a certain URL::
1213

13-
$this->assertGreaterThan(
14-
0,
15-
$crawler->filter('html:contains("Hello World")')->count()
16-
);
14+
$this->assertSame(301, $client->getResponse()->getStatusCode());
15+
$this->assertSame('https://example.com', $client->getResponse()->headers->get('Location'));
1716

18-
Now here is the example with the assertions specific to Symfony::
17+
This is the same example using the assertions provided by Symfony::
1918

20-
$this->assertSelectorTextContains('html', 'Hello World');
19+
$this->assertResponseRedirects('https://example.com', 301);
2120

2221
.. note::
2322

@@ -64,9 +63,9 @@ Crawler
6463

6564
- ``assertSelectorExists()``
6665
- ``assertSelectorNotExists()``
67-
- ``assertSelectorTextContains()``
68-
- ``assertSelectorTextSame()``
69-
- ``assertSelectorTextNotContains()``
66+
- ``assertSelectorTextContains()`` (note: it only checks the first selector occurrence)
67+
- ``assertSelectorTextSame()`` (note: it only checks the first selector occurrence)
68+
- ``assertSelectorTextNotContains()`` (note: it only checks the first selector occurrence)
7069
- ``assertPageTitleSame()``
7170
- ``assertPageTitleContains()``
7271
- ``assertInputValueSame()``

0 commit comments

Comments
 (0)
0