-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Testing] Fix phpunit test dir paths #3343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ it has its own excellent `documentation`_. | |
needed 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/`` subdirectory of your bundles. If you follow | ||
this rule, then you can run all of your application's tests with the following | ||
command: | ||
|
||
|
@@ -686,7 +686,7 @@ their type:: | |
Testing Configuration | ||
--------------------- | ||
|
||
The Client used by functional tests creates a Kernel that runs in a special | ||
The client used by functional tests creates a Kernel that runs in a special | ||
``test`` environment. Since Symfony loads the ``app/config/config_test.yml`` | ||
in the ``test`` environment, you can tweak any of your application's settings | ||
specifically for testing. | ||
|
@@ -766,47 +766,76 @@ PHPUnit Configuration | |
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Each application has its own PHPUnit configuration, stored in the | ||
``phpunit.xml.dist`` file. You can edit this file to change the defaults or | ||
create a ``phpunit.xml`` file to tweak the configuration for your local machine. | ||
``app/phpunit.xml.dist`` file. You can edit this file to change the defaults or | ||
create a ``app/phpunit.xml`` file to setup a configuration for your local | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [...] an |
||
machine only. | ||
|
||
.. tip:: | ||
|
||
Store the ``phpunit.xml.dist`` file in your code repository, and ignore the | ||
Store the ``phpunit.xml.dist`` file in your code repository and ignore the | ||
``phpunit.xml`` file. | ||
|
||
By default, only the tests stored in "standard" bundles are run by the | ||
``phpunit`` command (standard being tests in the ``src/*/Bundle/Tests`` or | ||
``src/*/Bundle/*Bundle/Tests`` directories) But you can easily add more | ||
directories. For instance, the following configuration adds the tests from | ||
the installed third-party bundles: | ||
By default, only the tests from your own custom bundles stored in the standard | ||
directories ``src/*/*Bundle/Tests`` or ``src/*/Bundle/*Bundle/Tests`` are run | ||
by the ``phpunit`` command: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [...] command, as configured in the |
||
|
||
.. code-block:: xml | ||
|
||
<!-- hello/phpunit.xml.dist --> | ||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>../src/*/*Bundle/Tests</directory> | ||
<directory>../src/Acme/Bundle/*Bundle/Tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<!-- app/phpunit.xml.dist --> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line |
||
<phpunit> | ||
<!-- ... --> | ||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>../src/*/*Bundle/Tests</directory> | ||
<directory>../src/*/Bundle/*Bundle/Tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<!-- ... --> | ||
</phpunit> | ||
|
||
But you can easily add more directories. For instance, the following | ||
configuration adds tests from a custom ``lib/tests`` directory: | ||
|
||
.. code-block:: xml | ||
|
||
<!-- app/phpunit.xml.dist --> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line |
||
<phpunit> | ||
<!-- ... --> | ||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<!-- ... ---> | ||
<directory>../lib/tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<!-- ... ---> | ||
</phpunit> | ||
|
||
To include other directories in the code coverage, also edit the ``<filter>`` | ||
section: | ||
|
||
.. code-block:: xml | ||
|
||
<!-- ... --> | ||
<filter> | ||
<whitelist> | ||
<directory>../src</directory> | ||
<exclude> | ||
<directory>../src/*/*Bundle/Resources</directory> | ||
<directory>../src/*/*Bundle/Tests</directory> | ||
<directory>../src/Acme/Bundle/*Bundle/Resources</directory> | ||
<directory>../src/Acme/Bundle/*Bundle/Tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<!-- app/phpunit.xml.dist --> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line |
||
<phpunit> | ||
<!-- ... --> | ||
<filter> | ||
<whitelist> | ||
<directory>../src</directory> | ||
<directory>../lib</directory> | ||
<exclude> | ||
<directory>../src/*/*Bundle/Resources</directory> | ||
<directory>../src/*/*Bundle/Tests</directory> | ||
<directory>../src/*/Bundle/*Bundle/Resources</directory> | ||
<directory>../src/*/Bundle/*Bundle/Tests</directory> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe just fold all not changed lines? <whitelist>
<!-- ... -->
<directory>../lib</directory>
<exclude>
<!-- ... -->
<directory>../lib/tests</directory>
</exclude>
</whitelist> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. Thought about this, too. |
||
<directory>../lib/tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<!-- ... ---> | ||
</phpunit> | ||
|
||
Learn more | ||
---------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client, it refers to an object, just like Kernel