@@ -11,14 +11,16 @@ using both functional and unit tests.
11
11
The PHPUnit Testing Framework
12
12
-----------------------------
13
13
14
- Symfony integrates with an independent library - called PHPUnit - to give
15
- you a rich testing framework. This article won't cover PHPUnit itself, but
16
- it has its own excellent `documentation `_.
14
+ Symfony integrates with an independent library called ` PHPUnit `_ to give you a
15
+ rich testing framework. This article won't cover PHPUnit itself, which has its
16
+ own excellent `documentation `_.
17
17
18
- .. note ::
18
+ Before creating your first test, install the `PHPUnit Bridge component `_, which
19
+ wraps the original PHPUnit binary to provide additional features:
20
+
21
+ .. code-block :: terminal
19
22
20
- It's recommended to use the latest stable PHPUnit version, `installed as
21
- PHAR `_.
23
+ $ composer require --dev symfony/phpunit-bridge
22
24
23
25
Each test - whether it's a unit test or a functional test - is a PHP class
24
26
that should live in the ``Tests/ `` subdirectory of your bundles. If you follow
@@ -27,11 +29,10 @@ command:
27
29
28
30
.. code-block :: terminal
29
31
30
- # specify the configuration directory on the command line
31
- $ phpunit -c app/
32
+ # the -c option specifies the directory where PHPUnit config is stored
33
+ $ ./vendor/bin/simple- phpunit -c app/
32
34
33
- The ``-c `` option tells PHPUnit to look in the ``app/ `` directory for a configuration
34
- file. If you're curious about the PHPUnit options, check out the ``app/phpunit.xml.dist ``
35
+ If you're curious about the PHPUnit options, check out the ``app/phpunit.xml.dist ``
35
36
file.
36
37
37
38
.. tip ::
@@ -101,16 +102,16 @@ Running tests for a given file or directory is also very easy:
101
102
.. code-block :: terminal
102
103
103
104
# run all tests of the application
104
- $ phpunit -c app
105
+ $ ./vendor/bin/simple- phpunit -c app
105
106
106
107
# run all tests in the Util directory
107
- $ phpunit -c app src/AppBundle/Tests/Util
108
+ $ ./vendor/bin/simple- phpunit -c app src/AppBundle/Tests/Util
108
109
109
110
# run tests for the Calculator class
110
- $ phpunit -c app src/AppBundle/Tests/Util/CalculatorTest.php
111
+ $ ./vendor/bin/simple- phpunit -c app src/AppBundle/Tests/Util/CalculatorTest.php
111
112
112
113
# run all tests for the entire Bundle
113
- $ phpunit -c app src/AppBundle/
114
+ $ ./vendor/bin/simple- phpunit -c app src/AppBundle/
114
115
115
116
.. index ::
116
117
single: Tests; Functional tests
@@ -924,6 +925,7 @@ Learn more
924
925
* :doc: `/components/dom_crawler `
925
926
* :doc: `/components/css_selector `
926
927
927
- .. _`$_SERVER ` : http ://php.net/manual/en/reserved.variables.server.php
928
+ .. _`PHPUnit ` : https ://phpunit.de/
928
929
.. _`documentation` : https://phpunit.de/manual/current/en/
929
- .. _`installed as PHAR` : https://phpunit.de/manual/current/en/installation.html#installation.phar
930
+ .. _`PHPUnit Bridge component` : https://symfony.com/components/PHPUnit%20Bridge
931
+ .. _`$_SERVER` : http://php.net/manual/en/reserved.variables.server.php
0 commit comments