Skip to content
Closed
Prev Previous commit
Next Next commit
[to be squashed] took 3rd feedbacks into account
Took @cordoval and @xabbuh feedback into account: * fixed configuration formating * splitted long sentences
  • Loading branch information
Loïc Chardonnet committed May 13, 2015
commit b521478402fa13b9dd95825c58ecb5a5397fff29
27 changes: 15 additions & 12 deletions cookbook/bundles/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Standard Edition's front controller looks like this::
// Dump the Response's headers and print the Response's content
$response->send();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove this block - it's a bit of a maintenance problem. Instead, just describe how you could create a kernel and a "fake" request in order to test your bundle.


In this example Symfony is used as an application that mimicks the HTTP protocol,
In this example, Symfony is used as an application that mimicks the HTTP protocol,
which means that it is possible to write transversal tests (System Tests) by building
"manually" a ``Request``, giving it to our application and then check the returned ``Response``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"[...] by manually building a Request [...], passing it to the application and checking the returned Response." (I used bold text to emphasize the changes)


Expand All @@ -31,10 +31,13 @@ This article provides examples on how to write such tests with third party bundl
Creating a Minimal AppKernel
----------------------------

Third party bundles cannot be run on their own, they need an application. Instead
of creating a separate application, install the bundle in it and then check how things turn out,
it is possible to create a minimalistic ``AppKernel`` inside the bundle, for testing
and showcase purposes.
Third party bundles cannot be ran standalone, they need an application.
It is possible to create a minimalistic ``AppKernel`` inside the bundle for testing
and showcase purposes, instead of:

1. creating a separate application
2. install the bundle in it
3. then check how things turn out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reSt uses #. for numbered lists. Also, we normally capitialize the first word of each list item and we end it with a semi-colon (except from the last one, which ends with a full stop)


If the third party bundle is named ``AcmeMyBundle``, the ``AppKernel`` could look like this::

Expand Down Expand Up @@ -65,7 +68,7 @@ If the third party bundle is named ``AcmeMyBundle``, the ``AppKernel`` could loo
``AppKernel`` adds a direct dependency on Symfony's FrameworkBundle, which can be
installed by running the following command: ``composer require --dev symfony/framework-bundle``.

In its minimum state ``AppKernel`` requires only one configuration parameter, ``secret``::
In its minimum state ``AppKernel`` requires only one configuration parameter, ``secret``:

.. config-block:: yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be code-block


Expand All @@ -74,7 +77,7 @@ In its minimum state ``AppKernel`` requires only one configuration parameter, ``
secret: Th1s1sS3cr3t!

Symfony applications generate cache and logs directories, which can be ignored by
adding those lines to ``.gitignore``::
adding those lines to ``.gitignore``:

.. code-block::

Expand All @@ -101,7 +104,7 @@ front controller similar to the one that can be found in Symfony's Standard Edit
$response->send();

With this it becomes possible to browse the page. A way to do it without having to configure
a web server is to run the following command::
a web server is to run the following command:

.. code-block:: bash

Expand Down Expand Up @@ -130,7 +133,7 @@ similar to the one that can be found in Symfony's Standard Edition::
$application = new Application($kernel);
$application->run();

With this it becomes possible to run manually the command::
With this it becomes possible to run manually the command:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"[...] the console"?


.. code-block:: bash

Expand All @@ -142,7 +145,7 @@ Automated Tests
Manual tests are great to get a quick idea of what the bundle does. But writing
automated tests is even better!

The first step is to install a test framework like PHPUnit::
The first step is to install a test framework like PHPUnit:

.. code-block:: bash

Expand All @@ -152,7 +155,7 @@ The first step is to install a test framework like PHPUnit::

The steps should be similar with other tests frameworks.

Then the second one is to configure it to use composer's autoloading::
Then the second one is to configure it to use composer's autoloading:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composer


.. config-block:: xml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you sould add something saying it is phpunit.xml.dist

Expand All @@ -172,7 +175,7 @@ Then the second one is to configure it to use composer's autoloading::
</testsuites>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest showing the way to configure the code coverage whitelist too (ignoring the Tests folder and the vendor folder to avoid messy reports)

</phpunit>

With these two simple steps it becomes possible to run the test suite with the following command::
With these two simple steps it becomes possible to run the test suite with the following command:

.. code-block:: bash

Expand Down