Skip to content

Commit 0cf7e63

Browse files
committed
Merge branch '6.4' into 7.2
* 6.4: [Testing] Reorganize the introduction of some articles
2 parents cbc6c87 + 104e43c commit 0cf7e63

File tree

2 files changed

+50
-54
lines changed

2 files changed

+50
-54
lines changed

testing.rst

+31-29
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,38 @@ Whenever you write a new line of code, you also potentially add new bugs.
55
To build better and more reliable applications, you should test your code
66
using both functional and unit tests.
77

8-
.. _testing-installation:
8+
Symfony integrates with an independent library called `PHPUnit`_ to give you a
9+
rich testing framework. This article covers the PHPUnit basics you'll need to
10+
write Symfony tests. To learn everything about PHPUnit and its features, read
11+
the `official PHPUnit documentation`_.
12+
13+
Types of Tests
14+
--------------
15+
16+
There are many types of automated tests and precise definitions often
17+
differ from project to project. In Symfony, the following definitions are
18+
used. If you have learned something different, that is not necessarily
19+
wrong, just different from what the Symfony documentation is using.
20+
21+
`Unit Tests`_
22+
These tests ensure that *individual* units of source code (e.g. a single
23+
class) behave as intended.
24+
25+
`Integration Tests`_
26+
These tests test a combination of classes and commonly interact with
27+
Symfony's service container. These tests do not yet cover the fully
28+
working application, those are called *Application tests*.
29+
30+
`Application Tests`_
31+
Application tests (also known as functional tests) test the behavior of a
32+
complete application. They make HTTP requests (both real and simulated ones)
33+
and test that the response is as expected.
934

10-
The PHPUnit Testing Framework
11-
-----------------------------
35+
.. _testing-installation:
36+
.. _the-phpunit-testing-framework:
1237

13-
Symfony integrates with an independent library called `PHPUnit`_ to give
14-
you a rich testing framework. This article won't cover PHPUnit itself,
15-
which has its own excellent `documentation`_.
38+
Installation
39+
------------
1640

1741
Before creating your first test, install ``symfony/test-pack``, which installs
1842
some other packages needed for testing (such as ``phpunit/phpunit``):
@@ -44,28 +68,6 @@ your test into multiple "test suites").
4468
missing, you can try running the recipe again using
4569
``composer recipes:install phpunit/phpunit --force -v``.
4670

47-
Types of Tests
48-
--------------
49-
50-
There are many types of automated tests and precise definitions often
51-
differ from project to project. In Symfony, the following definitions are
52-
used. If you have learned something different, that is not necessarily
53-
wrong, just different from what the Symfony documentation is using.
54-
55-
`Unit Tests`_
56-
These tests ensure that *individual* units of source code (e.g. a single
57-
class) behave as intended.
58-
59-
`Integration Tests`_
60-
These tests test a combination of classes and commonly interact with
61-
Symfony's service container. These tests do not yet cover the fully
62-
working application, those are called *Application tests*.
63-
64-
`Application Tests`_
65-
Application tests test the behavior of a complete application. They
66-
make HTTP requests (both real and simulated ones) and test that the
67-
response is as expected.
68-
6971
Unit Tests
7072
----------
7173

@@ -1159,7 +1161,7 @@ Learn more
11591161
/components/css_selector
11601162

11611163
.. _`PHPUnit`: https://phpunit.de/
1162-
.. _`documentation`: https://docs.phpunit.de/
1164+
.. _`official PHPUnit documentation`: https://docs.phpunit.de/
11631165
.. _`Writing Tests for PHPUnit`: https://docs.phpunit.de/en/10.5/writing-tests-for-phpunit.html
11641166
.. _`PHPUnit documentation`: https://docs.phpunit.de/en/10.5/configuration.html
11651167
.. _`unit test`: https://en.wikipedia.org/wiki/Unit_testing

testing/end_to_end.rst

+19-25
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
11
End-to-End Testing
22
==================
33

4-
The Panther component allows to drive a real web browser with PHP to create
5-
end-to-end tests.
4+
End-to-end tests simulate how real users interact with your application through
5+
a browser. They focus on verifying your user interface and the outcomes of user
6+
actions (like confirming that clicking a button sends an email).
7+
8+
Unlike :ref:`application tests <functional-tests>`, these tests run in a real
9+
browser that can work in headless mode (without a graphical interface) for CI
10+
environments or with a graphical interface for debugging.
11+
12+
Symfony provides a component called **Panther** to run end-to-end tests. Panther
13+
lets you run tests in a real browser and offers unique features not available in
14+
other test types:
15+
16+
* Taking screenshots at any point during the test;
17+
* Executing JavaScript on your pages;
18+
* Supporting everything Chrome or Firefox does;
19+
* Simpler testing of real-time applications (e.g. WebSockets, Server-Sent Events with Mercure).
620

721
Installation
822
------------
923

24+
Before creating and running your first end-to-end tests, run the following command
25+
to install the needed dependencies:
26+
1027
.. code-block:: terminal
1128
1229
$ composer require symfony/panther
1330
1431
.. include:: /components/require_autoload.rst.inc
1532

16-
Introduction
17-
------------
18-
19-
End to end tests are a special type of application tests that
20-
simulate a real user interacting with your application. They are
21-
typically used to test the user interface (UI) of your application
22-
and the effects of these interactions (e.g. when I click on this button, a mail
23-
must be sent). The difference with functional tests detailed above is
24-
that End-to-End tests use a real browser instead of a simulated one. This
25-
browser can run in headless mode (without a graphical interface) or not.
26-
The first option is convenient for running tests in a Continuous Integration
27-
(CI), while the second one is useful for debugging purpose.
28-
29-
This is the purpose of Panther, a component that provides a real browser
30-
to run your tests. Here are a few things that make Panther special, compared
31-
to other testing tools provided by Symfony:
32-
33-
* Possibility to take screenshots of the browser at any time during the test
34-
* The JavaScript code contained in webpages is executed
35-
* Panther supports everything that Chrome (or Firefox) implements
36-
* Convenient way to test real-time applications (e.g. WebSockets, Server-Sent Events
37-
with Mercure, etc.)
38-
3933
Installing Web Drivers
4034
~~~~~~~~~~~~~~~~~~~~~~
4135

0 commit comments

Comments
 (0)