Problem/Motivation

printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" provides a massive help when writing/debugging tests as you can see the page responses. However, in a scenario where you're using a temporary server (e.g. php -S localhost:8888) rather than going through the full webserver, the output links aren't correct as it uses http://localhost:8888 as the base url for the links.

Proposed resolution

Allow use of an environmental variable to override the base url for those links.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewbelcher created an issue. See original summary.

andrewbelcher’s picture

Here's a patch.

dawehner’s picture

I'm wondering whether we should fix $GLOBALS['base_url'] instead? Am I missing something?

andrewbelcher’s picture

I'd assumed $GLOBALS['base_url'] would be for the base URL that the test makes requests to (or at least would be expected to match that), which is why I made use of something separate.

dawehner’s picture

However, in a scenario where you're using a temporary server (e.g. php -S localhost:8888) rather than going through the full webserver, the output links aren't correct as it uses http://localhost:8888 as the base url for the links.

I think I'm missing something. Why are these links incorrect?

andrewbelcher’s picture

If you're using a remote server (e.g. a development box on digital ocean's cloud infra), to be able to view those files you need to use the servers URL, not localhost.

dawehner’s picture

Gotcha, that makes sense. Do you mind documenting it in the phpunit.xml maybe?

jhedstrom’s picture

Status: Needs review » Needs work

Needs work to document this in phpunit.xml.dist as noted in #7.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewbelcher’s picture

Here's an updated patch with the documentation.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

This would also be useful in CI environments where tests might be run against http://localhost, but the site itself (where the output html would be accessed) would be at an externally accessible URL.

I think the patch in #10 looks good and has addressed the above feedback.

alexpott’s picture

Category: Feature request » Task
Status: Reviewed & tested by the community » Fixed

Committed and pushed a74c8c2b7d to 9.0.x and ba96ab0d0d to 8.9.x and d338a3d4e6 to 8.8.x. Thanks!

Backported to 8.8.x as a test only fix.

  • alexpott committed a74c8c2 on 9.0.x
    Issue #2996476 by andrewbelcher, dawehner, jhedstrom: Allow setting the...

  • alexpott committed ba96ab0 on 8.9.x
    Issue #2996476 by andrewbelcher, dawehner, jhedstrom: Allow setting the...

  • alexpott committed d338a3d on 8.8.x
    Issue #2996476 by andrewbelcher, dawehner, jhedstrom: Allow setting the...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.