@@ -8,16 +8,15 @@ When doing functional tests, sometimes you need to make complex assertions in
8
8
order to check whether the ``Request ``, the ``Response `` or the ``Crawler ``
9
9
contain the expected information to make your test succeed.
10
10
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::
12
13
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'));
17
16
18
- Now here is the example with the assertions specific to Symfony::
17
+ This is the same example using the assertions provided by Symfony::
19
18
20
- $this->assertSelectorTextContains('html ', 'Hello World' );
19
+ $this->assertResponseRedirects('https://example.com ', 301 );
21
20
22
21
.. note ::
23
22
@@ -64,9 +63,9 @@ Crawler
64
63
65
64
- ``assertSelectorExists() ``
66
65
- ``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)
70
69
- ``assertPageTitleSame() ``
71
70
- ``assertPageTitleContains() ``
72
71
- ``assertInputValueSame() ``
0 commit comments