Skip to content

Commit

Permalink
minor symfony#13051 [Testing] Use a better example for Symfony assert…
Browse files Browse the repository at this point in the history
…s (javiereguiluz)

This PR was squashed before being merged into the 4.4 branch (closes symfony#13051).

Discussion
----------

[Testing] Use a better example for Symfony asserts

Fixes symfony#13036.

Commits
-------

bed8a5e [Testing] Use a better example for Symfony asserts
  • Loading branch information
javiereguiluz committed Feb 7, 2020
2 parents 1514ffb + bed8a5e commit 13ff783
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions testing/functional_tests_assertions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ When doing functional tests, sometimes you need to make complex assertions in
order to check whether the ``Request``, the ``Response`` or the ``Crawler``
contain the expected information to make your test succeed.

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

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

Now here is the example with the assertions specific to Symfony::
This is the same example using the assertions provided by Symfony::

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

.. note::

Expand Down Expand Up @@ -70,9 +69,9 @@ Crawler

- ``assertSelectorExists()``
- ``assertSelectorNotExists()``
- ``assertSelectorTextContains()``
- ``assertSelectorTextSame()``
- ``assertSelectorTextNotContains()``
- ``assertSelectorTextContains()`` (note: it only checks the first selector occurrence)
- ``assertSelectorTextSame()`` (note: it only checks the first selector occurrence)
- ``assertSelectorTextNotContains()`` (note: it only checks the first selector occurrence)
- ``assertPageTitleSame()``
- ``assertPageTitleContains()``
- ``assertInputValueSame()``
Expand Down

0 comments on commit 13ff783

Please sign in to comment.