@@ -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
851850Additional 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