Skip to content

Commit 9b0f3a0

Browse files
committed
feature #8577 Migrating Tests topics to Symfony Flex structure (yceruto)
This PR was merged into the master branch. Discussion ---------- Migrating Tests topics to Symfony Flex structure #8569 continuation. I've excluded `creating-the-project.rst` guide, because it needs to be changed completely. Commits ------- 9dd5a9d Migrating Tests topics to Symfony Flex structure
2 parents 2a8a564 + 9dd5a9d commit 9b0f3a0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

best_practices/tests.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ functional tests, you can quickly spot any big errors before you deploy them:
2828

2929
A functional test can be as easy as this::
3030

31-
// tests/AppBundle/ApplicationAvailabilityFunctionalTest.php
32-
namespace Tests\AppBundle;
31+
// tests/ApplicationAvailabilityFunctionalTest.php
32+
namespace App\Tests;
3333

3434
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
3535

testing.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ called ``Calculator`` in the ``Util/`` directory of the app bundle::
6262
}
6363
}
6464

65-
To test this, create a ``CalculatorTest`` file in the ``tests/AppBundle/Util`` directory
65+
To test this, create a ``CalculatorTest`` file in the ``tests/Util`` directory
6666
of your application::
6767

6868
// tests/Util/CalculatorTest.php
@@ -85,9 +85,9 @@ of your application::
8585

8686
.. note::
8787

88-
By convention, the ``tests/AppBundle`` directory should replicate the directory
88+
By convention, the ``tests/`` directory should replicate the directory
8989
of your bundle for unit tests. So, if you're testing a class in the
90-
``src/Util/`` directory, put the test in the ``tests/AppBundle/Util/``
90+
``src/Util/`` directory, put the test in the ``tests/Util/``
9191
directory.
9292

9393
Just like in your real application - autoloading is automatically enabled
@@ -102,13 +102,13 @@ Running tests for a given file or directory is also very easy:
102102
$ phpunit
103103
104104
# run all tests in the Util directory
105-
$ phpunit tests/AppBundle/Util
105+
$ phpunit tests/Util
106106
107107
# run tests for the Calculator class
108-
$ phpunit tests/AppBundle/Util/CalculatorTest.php
108+
$ phpunit tests/Util/CalculatorTest.php
109109
110110
# run all tests for the entire Bundle
111-
$ phpunit tests/AppBundle/
111+
$ phpunit tests/
112112
113113
.. index::
114114
single: Tests; Functional tests
@@ -129,7 +129,7 @@ tests as far as PHPUnit is concerned, but they have a very specific workflow:
129129
Your First Functional Test
130130
~~~~~~~~~~~~~~~~~~~~~~~~~~
131131

132-
Functional tests are simple PHP files that typically live in the ``tests/AppBundle/Controller``
132+
Functional tests are simple PHP files that typically live in the ``tests/Controller``
133133
directory for your bundle. If you want to test the pages handled by your
134134
``PostController`` class, start by creating a new ``PostControllerTest.php``
135135
file that extends a special ``WebTestCase`` class.
@@ -757,7 +757,7 @@ Testing Configuration
757757
---------------------
758758

759759
The Client used by functional tests creates a Kernel that runs in a special
760-
``test`` environment. Since Symfony loads the ``app/config/config_test.yml``
760+
``test`` environment. Since Symfony loads the ``config/packages/test/*.yaml``
761761
in the ``test`` environment, you can tweak any of your application's settings
762762
specifically for testing.
763763

@@ -769,15 +769,15 @@ configuration option:
769769

770770
.. code-block:: yaml
771771
772-
# app/config/config_test.yml
772+
# config/packages/test/swiftmailer.yaml
773773
774774
# ...
775775
swiftmailer:
776776
disable_delivery: true
777777
778778
.. code-block:: xml
779779
780-
<!-- app/config/config_test.xml -->
780+
<!-- config/packages/test/swiftmailer.xml -->
781781
<?xml version="1.0" encoding="UTF-8" ?>
782782
<container xmlns="http://symfony.com/schema/dic/services"
783783
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -793,7 +793,7 @@ configuration option:
793793
794794
.. code-block:: php
795795
796-
// app/config/config_test.php
796+
// config/packages/test/swiftmailer.php
797797
798798
// ...
799799
$container->loadFromExtension('swiftmailer', array(
@@ -847,7 +847,7 @@ only.
847847
Store the ``phpunit.xml.dist`` file in your code repository and ignore
848848
the ``phpunit.xml`` file.
849849

850-
By default, only the tests stored in ``/tests`` are run via the ``phpunit`` command,
850+
By default, only the tests stored in ``tests/`` are run via the ``phpunit`` command,
851851
as configured in the ``phpunit.xml.dist`` file:
852852

853853
.. code-block:: xml

0 commit comments

Comments
 (0)