Skip to content

Commit 78e0a19

Browse files
committed
Some rewords
1 parent eb71ee4 commit 78e0a19

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

frontend/asset_mapper.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ If you look at the HTML in your page, the URL will be something
7777
like: ``/assets/images/duck-3c16d9220694c0e56d8648f25e6035e9.png``. If you change
7878
the file, the version part of the URL will also change automatically.
7979

80+
.. _asset-mapper-compile-assets:
81+
8082
Serving Assets in dev vs prod
8183
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8284

testing/end_to_end.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -799,18 +799,20 @@ variable to ``false`` in your style file:
799799
800800
$enable-smooth-scroll: false;
801801
802-
Assets not loading (PHP built-in server only)
803-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
802+
Assets not Loading when Using the PHP Built-In Server
803+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
804804

805-
You may face cases where your assets are not loaded while running your tests.
806-
Because Panther use the `PHP built-in server`_ to serve your app, if your assets files
807-
(or any requested URI that not a ``.php`` file) does not exist in your public directory
808-
(e.g. rendered by your Symfony app), the built-in server will return a 404 not found.
805+
Sometimes, your assets might not load during tests. This happens because Panther
806+
uses the `PHP built-in server`_ to serve your app. If asset files (or any requested
807+
URI that's not a ``.php`` file) aren't in your public directory, the built-in
808+
server will return a 404 error. This often happens when letting the :doc:`AssetMapper component </frontend/asset_mapper>`
809+
handle your application assets in the ``dev`` environment.
809810

810-
This can happen when using :doc:`AssetMapper component </frontend/asset_mapper>`
811-
if you let your Symfony app handle your assets in dev environment.
811+
One solution when using AssetMapper is to ref:`compile assets <asset-mapper-compile-assets>`
812+
before running your tests. This will also speed up your tests, as Symfony won't
813+
need to handle the assets, allowing the PHP built-in server to serve them directly.
812814

813-
To solve this, add a ``tests/router.php``::
815+
Another option is to create a file called ``tests/router.php`` and add the following to it::
814816

815817
// tests/router.php
816818
if (is_file($_SERVER['DOCUMENT_ROOT'].\DIRECTORY_SEPARATOR.$_SERVER['SCRIPT_NAME'])) {
@@ -827,7 +829,8 @@ To solve this, add a ``tests/router.php``::
827829

828830
require $script;
829831

830-
Then declare it as a router for Panther server in ``phpunit.xml.dist`` using ``PANTHER_WEB_SERVER_ROUTER`` var:
832+
Then declare it as a router for Panther server in ``phpunit.xml.dist`` using the
833+
``PANTHER_WEB_SERVER_ROUTER`` environment variable:
831834

832835
.. code-block:: xml
833836
@@ -836,17 +839,13 @@ Then declare it as a router for Panther server in ``phpunit.xml.dist`` using ``P
836839
<!-- ... -->
837840
<php>
838841
<!-- ... -->
839-
<server name="PANTHER_WEB_SERVER_ROUTER" value="../tests/router.php"/>
842+
<server name="PANTHER_WEB_SERVER_ROUTER" value="./tests/router.php"/>
840843
</php>
841844
</phpunit>
842845
843-
Credit from `Testing Part 2 Functional Testing on Symfony cast`_ were you can see more about this case.
846+
.. seealso::
844847

845-
.. note::
846-
847-
When using :doc:`AssetMapper component </frontend/asset_mapper>`, you can also compile your assets before running
848-
your tests. It will make your tests faster because Symfony will not have to handle them, the built-in server
849-
will serve them directly.
848+
See the `Functional Testing tutorial`_ on SymfonyCasts.
850849

851850
Additional Documentation
852851
------------------------
@@ -875,4 +874,4 @@ documentation:
875874
.. _`AppVeyor`: https://www.appveyor.com/
876875
.. _`LiipFunctionalTestBundle`: https://github.com/liip/LiipFunctionalTestBundle
877876
.. _`PHP built-in server`: https://www.php.net/manual/en/features.commandline.webserver.php
878-
.. _`Testing Part 2 Functional Testing on Symfony cast`: https://symfonycasts.com/screencast/last-stack/testing
877+
.. _`Functional Testing tutorial`: https://symfonycasts.com/screencast/last-stack/testing

0 commit comments

Comments
 (0)