phpsymfonyphpunitsymfony-panther

PHPUnit+Panther hijacks/intercepts /admin route


In an existing Symfony project with working tests in PHPUnit, I switched from using Browser-Kit to Panther (to address the tests' shortcomings regarding JavaScript).

At first, migrating the tests onto Panther seemed straightforward. But then I couldn't get the tests for the web-application's administration panels working. All the requests to any route /admin/* returns a very "phpinfo()-/apache-feely" 404 response:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>404 Not Found</title><style>
body { background-color: #fcfcfc; color: #333333; margin: 0; padding:0; }
h1 { font-size: 1.5em; font-weight: normal; background-color: #9999cc; min-height:2em; line-height:2em; border-bottom: 1px inset black; margin: 0; }
h1, p { padding-left: 10px; }
code.url { background-color: #eeeeee; font-family:monospace; padding:0 2px;}
</style>
</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/admin/company/new</code> was not found on this server.</p></body></html>

Other inexistent routes return the regular symfony exception/error debug page.

If I map the administration controllers to another route (e.g. /administration/*) I get the expected/correct response.

Furthermore, I am unable to reproduce the issue outside the PHPUnit/Panther pipeline, so to speak: if I (enable and) run the internal server (symfony/web-server-bundle) with test-environment, I receive the expected/correct responses also on the /admin/* routes.

If I set PHPUnit/Panther to use a different port, the problem persists.

I'm out of my depth which server-instance is used by PHPUnit/Panther (also because it is not apparent in the faulty 404-response), but it seems as if this server-instance specifically intercepts the /admin/* routes outside of the scope of the symfony web-application in order to respond a 404.

Does anybody know what server-instance is being launched under the hood in PHPUnit/Panther, or even where I can disable the wrongfully intercepted route, so to speak?

OS: Ubuntu 18.04
PHP: 7.2.24-0ubuntu0.18.04.1
Symfony: 4.4
PHPUnit: 7.5

Solution

  • Panther starts a PHP debug-server with ever so slightly different parameters/settings which doesn't allow for coexistence of routes with the same name as folders in public directory. The symfony-integrated web-server and production-servers (apache and nginx) happily serve such overlapping routes, mapped to controllers and resources in public folders.

    See Panther issue #491.