Skip to content

Commit

Permalink
[#5917] Finding some more places with the old directory structure ref…
Browse files Browse the repository at this point in the history
…erenced
  • Loading branch information
weaverryan committed Nov 30, 2015
1 parent 0e53bb5 commit 3083e90
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
41 changes: 18 additions & 23 deletions book/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ it has its own excellent `documentation`_.
to use version 4.2 or higher to test the Symfony core code itself).

Each test - whether it's a unit test or a functional test - is a PHP class
that should live in the ``Tests/`` subdirectory of your bundles. If you follow
that should live in the ``tests/`` directory of your application. If you follow
this rule, then you can run all of your application's tests with the following
command:

.. code-block:: bash
# specify the configuration directory on the command line
$ phpunit
PHPunit is configured by the ``phpunit.xml.dist`` file in the root of your
Expand Down Expand Up @@ -63,11 +62,11 @@ called ``Calculator`` in the ``Util/`` directory of the app bundle::
}
}

To test this, create a ``CalculatorTest`` file in the ``Tests/Util`` directory
To test this, create a ``CalculatorTest`` file in the ``tests/AppBundle/Util`` directory
of your bundle::

// src/AppBundle/Tests/Util/CalculatorTest.php
namespace AppBundle\Tests\Util;
// tests/AppBundle/Util/CalculatorTest.php
namespace Tests\AppBundle\Util;

use AppBundle\Util\Calculator;

Expand All @@ -85,13 +84,13 @@ of your bundle::

.. note::

By convention, the ``Tests/`` sub-directory should replicate the directory
of your bundle for unit tests. So, if you're testing a class in your
bundle's ``Util/`` directory, put the test in the ``Tests/Util/``
By convention, the ``Tests/AppBundle`` directory should replicate the directory
of your bundle for unit tests. So, if you're testing a class in the
``AppBundle/Util/`` directory, put the test in the ``tests/AppBundle/Util/``
directory.

Just like in your real application - autoloading is automatically enabled
via the ``bootstrap.php.cache`` file (as configured by default in the
via the ``autoload.php`` file (as configured by default in the
``phpunit.xml.dist`` file).

Running tests for a given file or directory is also very easy:
Expand All @@ -102,13 +101,13 @@ Running tests for a given file or directory is also very easy:
$ phpunit
# run all tests in the Util directory
$ phpunit src/AppBundle/Tests/Util
$ phpunit tests/AppBundle/Util
# run tests for the Calculator class
$ phpunit src/AppBundle/Tests/Util/CalculatorTest.php
$ phpunit tests/AppBundle/Util/CalculatorTest.php
# run all tests for the entire Bundle
$ phpunit src/AppBundle/
$ phpunit tests/AppBundle/
.. index::
single: Tests; Functional tests
Expand All @@ -129,15 +128,15 @@ tests as far as PHPUnit is concerned, but they have a very specific workflow:
Your First Functional Test
~~~~~~~~~~~~~~~~~~~~~~~~~~

Functional tests are simple PHP files that typically live in the ``Tests/Controller``
directory of your bundle. If you want to test the pages handled by your
Functional tests are simple PHP files that typically live in the ``tests/AppBundle/Controller``
directory for your bundle. If you want to test the pages handled by your
``PostController`` class, start by creating a new ``PostControllerTest.php``
file that extends a special ``WebTestCase`` class.

As an example, a test could look like this::

// src/AppBundle/Tests/Controller/PostControllerTest.php
namespace AppBundle\Tests\Controller;
// tests/AppBundle/Controller/PostControllerTest.php
namespace Tests\AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

Expand Down Expand Up @@ -810,10 +809,8 @@ only.
Store the ``phpunit.xml.dist`` file in your code repository and ignore
the ``phpunit.xml`` file.

By default, only the tests from your own custom bundles stored in the standard
directories ``src/*/*Bundle/Tests``, ``src/*/Bundle/*Bundle/Tests``,
``src/*Bundle/Tests`` are run by the ``phpunit`` command, as configured
in the ``phpunit.xml.dist`` file:
By default, only the tests stored in ``/tests`` are run via the ``phpunit`` command,
as configured in the ``phpunit.xml.dist`` file:

.. code-block:: xml
Expand All @@ -822,9 +819,7 @@ in the ``phpunit.xml.dist`` file:
<!-- ... -->
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<directory>../src/*Bundle/Tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
<!-- ... -->
Expand Down
2 changes: 1 addition & 1 deletion cookbook/configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ in your ``app.php`` and ``app_dev.php`` front controllers. If you simply
renamed the directory, you're fine. But if you moved it in some way, you
may need to modify these paths inside those files::

require_once __DIR__.'/../path/to/var/bootstrap.php.cache';
require_once __DIR__.'/../path/to/app/autoload.php';

You also need to change the ``extra.symfony-web-dir`` option in the
``composer.json`` file:
Expand Down
2 changes: 1 addition & 1 deletion cookbook/deployment/azure-website.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ directory with at least the following contents:

.. code-block:: text
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/var/cache/*
/app/config/parameters.yml
/var/logs/*
Expand Down
2 changes: 1 addition & 1 deletion cookbook/deployment/platformsh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Platform.sh how to deploy your application (read more about
# The mounts that will be performed when the package is deployed.
mounts:
"/var/cache": "shared:files/cache"
"/app/logs": "shared:files/logs"
"/var/logs": "shared:files/logs"
# The hooks that will be performed when the package is deployed.
hooks:
Expand Down
4 changes: 2 additions & 2 deletions cookbook/testing/bootstrap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ First, add the following file::
));
}

require __DIR__.'/bootstrap.php.cache';
require __DIR__.'/autoload.php';

Replace the test bootstrap file ``bootstrap.php.cache`` in ``phpunit.xml.dist``
Replace the test bootstrap file ``autoload.php`` in ``phpunit.xml.dist``
with ``tests.bootstrap.php``:

.. code-block:: xml
Expand Down
2 changes: 1 addition & 1 deletion quick_tour/the_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ and help you fix the problem quickly.
Using the Command Line Interface
--------------------------------

Each application comes with a command line interface tool (``app/console``)
Each application comes with a command line interface tool (``bin/console``)
that helps you maintain your application. It provides commands that boost
your productivity by automating tedious and repetitive tasks.

Expand Down

0 comments on commit 3083e90

Please sign in to comment.