Skip to content

[Testing] Use a better example for Symfony asserts #13051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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