@@ -15,10 +15,11 @@ Symfony integrates with an independent library - called PHPUnit - to give
15
15
you a rich testing framework. This article won't cover PHPUnit itself, but
16
16
it has its own excellent `documentation `_.
17
17
18
- .. note ::
18
+ First, install PHPUnit support in your Symfony application running this command:
19
+
20
+ .. code-block :: terminal
19
21
20
- It's recommended to use the latest stable PHPUnit version, `installed as
21
- PHAR `_.
22
+ $ composer require --dev phpunit
22
23
23
24
Each test - whether it's a unit test or a functional test - is a PHP class
24
25
that should live in the ``tests/ `` directory of your application. If you follow
@@ -27,7 +28,7 @@ command:
27
28
28
29
.. code-block :: terminal
29
30
30
- $ phpunit
31
+ $ ./bin/ phpunit
31
32
32
33
PHPUnit is configured by the ``phpunit.xml.dist `` file in the root of your
33
34
Symfony application.
@@ -99,16 +100,13 @@ Running tests for a given file or directory is also very easy:
99
100
.. code-block :: terminal
100
101
101
102
# run all tests of the application
102
- $ phpunit
103
+ $ ./bin/ phpunit
103
104
104
- # run all tests in the Util directory
105
- $ phpunit tests/Util
105
+ # run all tests in the Util/ directory
106
+ $ ./bin/ phpunit tests/Util
106
107
107
108
# run tests for the Calculator class
108
- $ phpunit tests/Util/CalculatorTest.php
109
-
110
- # run all tests for the entire Bundle
111
- $ phpunit tests/
109
+ $ ./bin/phpunit tests/Util/CalculatorTest.php
112
110
113
111
.. index ::
114
112
single: Tests; Functional tests
@@ -920,4 +918,3 @@ Learn more
920
918
921
919
.. _`$_SERVER` : http://php.net/manual/en/reserved.variables.server.php
922
920
.. _`documentation` : https://phpunit.de/manual/current/en/
923
- .. _`installed as PHAR` : https://phpunit.de/manual/current/en/installation.html#installation.phar
0 commit comments