@@ -21,13 +21,12 @@ it has its own excellent `documentation`_.
2121 to use version 4.2 or higher to test the Symfony core code itself).
2222
2323Each test - whether it's a unit test or a functional test - is a PHP class
24- that should live in the ``Tests / `` subdirectory of your bundles . If you follow
24+ that should live in the ``tests / `` directory of your application . If you follow
2525this rule, then you can run all of your application's tests with the following
2626command:
2727
2828.. code-block :: bash
2929
30- # specify the configuration directory on the command line
3130 $ phpunit
3231
3332 PHPunit is configured by the ``phpunit.xml.dist `` file in the root of your
@@ -63,11 +62,11 @@ called ``Calculator`` in the ``Util/`` directory of the app bundle::
6362 }
6463 }
6564
66- To test this, create a ``CalculatorTest `` file in the ``Tests /Util `` directory
65+ To test this, create a ``CalculatorTest `` file in the ``tests/AppBundle /Util `` directory
6766of your bundle::
6867
69- // src /AppBundle/Tests /Util/CalculatorTest.php
70- namespace AppBundle\ Tests\Util;
68+ // tests /AppBundle/Util/CalculatorTest.php
69+ namespace Tests\AppBundle \Util;
7170
7271 use AppBundle\Util\Calculator;
7372
@@ -85,13 +84,13 @@ of your bundle::
8584
8685.. note ::
8786
88- By convention, the ``Tests/ `` sub- directory should replicate the directory
89- of your bundle for unit tests. So, if you're testing a class in your
90- bundle's `` Util/ `` directory, put the test in the ``Tests /Util/ ``
87+ By convention, the ``Tests/AppBundle `` directory should replicate the directory
88+ of your bundle for unit tests. So, if you're testing a class in the
89+ `` AppBundle/ Util/ `` directory, put the test in the ``tests/AppBundle /Util/ ``
9190 directory.
9291
9392Just like in your real application - autoloading is automatically enabled
94- via the ``bootstrap .php.cache `` file (as configured by default in the
93+ via the ``autoload .php `` file (as configured by default in the
9594``phpunit.xml.dist `` file).
9695
9796Running tests for a given file or directory is also very easy:
@@ -102,13 +101,13 @@ Running tests for a given file or directory is also very easy:
102101 $ phpunit
103102
104103 # run all tests in the Util directory
105- $ phpunit src /AppBundle/Tests /Util
104+ $ phpunit tests /AppBundle/Util
106105
107106 # run tests for the Calculator class
108- $ phpunit src /AppBundle/Tests /Util/CalculatorTest.php
107+ $ phpunit tests /AppBundle/Util/CalculatorTest.php
109108
110109 # run all tests for the entire Bundle
111- $ phpunit src /AppBundle/
110+ $ phpunit tests /AppBundle/
112111
113112 .. index ::
114113 single: Tests; Functional tests
@@ -129,15 +128,15 @@ tests as far as PHPUnit is concerned, but they have a very specific workflow:
129128Your First Functional Test
130129~~~~~~~~~~~~~~~~~~~~~~~~~~
131130
132- Functional tests are simple PHP files that typically live in the ``Tests /Controller ``
133- directory of your bundle. If you want to test the pages handled by your
131+ Functional tests are simple PHP files that typically live in the ``tests/AppBundle /Controller ``
132+ directory for your bundle. If you want to test the pages handled by your
134133``PostController `` class, start by creating a new ``PostControllerTest.php ``
135134file that extends a special ``WebTestCase `` class.
136135
137136As an example, a test could look like this::
138137
139- // src /AppBundle/Tests /Controller/PostControllerTest.php
140- namespace AppBundle\ Tests\Controller;
138+ // tests /AppBundle/Controller/PostControllerTest.php
139+ namespace Tests\AppBundle \Controller;
141140
142141 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
143142
@@ -810,10 +809,8 @@ only.
810809 Store the ``phpunit.xml.dist `` file in your code repository and ignore
811810 the ``phpunit.xml `` file.
812811
813- By default, only the tests from your own custom bundles stored in the standard
814- directories ``src/*/*Bundle/Tests ``, ``src/*/Bundle/*Bundle/Tests ``,
815- ``src/*Bundle/Tests `` are run by the ``phpunit `` command, as configured
816- in the ``phpunit.xml.dist `` file:
812+ By default, only the tests stored in ``/tests `` are run via the ``phpunit `` command,
813+ as configured in the ``phpunit.xml.dist `` file:
817814
818815.. code-block :: xml
819816
@@ -822,9 +819,7 @@ in the ``phpunit.xml.dist`` file:
822819 <!-- ... -->
823820 <testsuites >
824821 <testsuite name =" Project Test Suite" >
825- <directory >../src/*/*Bundle/Tests</directory >
826- <directory >../src/*/Bundle/*Bundle/Tests</directory >
827- <directory >../src/*Bundle/Tests</directory >
822+ <directory >tests</directory >
828823 </testsuite >
829824 </testsuites >
830825 <!-- ... -->
0 commit comments