Skip to content

Commit

Permalink
[book][testing] Making new note about kernel dir shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Oct 30, 2011
1 parent c3e9ae1 commit ad9a55e
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions book/testing.rst
Expand Up @@ -124,31 +124,18 @@ simple functional test for ``DemoController`` that reads as follows::

.. tip::

While unit tests are built to test each class separately, functional tests
need to run the application. For a symfony application to run, it must be
bootstrapped correctly, but this is quite simple:

The phpunit.xml file needs to load app/bootstrap.php.cache which will do the boostrap.
Then your test has to load the kernel. When using the ``WebTestCase``, all you need to
do is make sure it can locate the kernel php file and the test will instantiate the kernel
with the ``test`` environment. If your phpunit.xml file is located in the same directory
as your AppKernel.php, this will work automatically. However, if you want to run tests
for a bundle or use a non-standard directory structure, you need to specify the location
of the kernel directory by defining the php environment variable ``KERNEL_DIR`` to point
to the directory containing the kernel.

The relevant parts of phpunit.xml.dist look like this::
To run your functional tests, the ``WebTestCase`` class bootstraps the
kernel of your application. In most cases, this happens automatically.
However, if your kernel is in a non-standard directory, you'll need
to modify your ``phpunit.xml.dist`` file to set the ``KERNEL_DIR`` environment
variable to the directory of your kernel::

<phpunit
...
bootstrap = "bootstrap.php.cache" >
...
<!-- if the kernel is not automatically found, enable and set to kernel path
<!-- ... -->
<php>
<server name="KERNEL_DIR" value="/path/to/your/app/" />
</php>
-->
...
<!-- ... -->
</phpunit>


Expand Down

0 comments on commit ad9a55e

Please sign in to comment.