-
- Notifications
You must be signed in to change notification settings - Fork 5.3k
[WIP] Added Test documentation for third party bundles #5232
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 1 commit
0338758
970a44a
cd2343b
b521478
2530489
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Took @cordoval and @xabbuh feedback into account: * fixed configuration formating * splitted long sentences
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -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(); | ||
| ||
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``. | ||
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. "[...] by manually building a | ||
| ||
| @@ -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 | ||
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. reSt uses | ||
| ||
If the third party bundle is named ``AcmeMyBundle``, the ``AppKernel`` could look like this:: | ||
| ||
| @@ -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 | ||
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. must be | ||
| ||
| @@ -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:: | ||
| ||
| @@ -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 | ||
| ||
| @@ -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: | ||
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. "[...] the console"? | ||
| ||
.. code-block:: bash | ||
| ||
| @@ -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 | ||
| ||
| @@ -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: | ||
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. Composer | ||
| ||
.. config-block:: xml | ||
| ||
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. you sould add something saying it is | ||
| @@ -172,7 +175,7 @@ Then the second one is to configure it to use composer's autoloading:: | |
</testsuites> | ||
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. 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 | ||
| ||
|
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.
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.