Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Updated: Comment #0
Problem/Motivation
Following #1888424: Make Drupal's URL generation logic available to HttpKernel, and minimize code repetition/divergence, the --url
flag for run-tests.sh
no longer works to specify a particular port. When tests are run, the port is ignored, and therefore any web tests that use the simpletest browser will fail because they are accessing the wrong URL. I'm not sure whether this also impacts other URL generation, but assuming it's related to our HttpKernel integration given the issue that introduced it.
Steps to reproduce
- Install Drupal to run on a port other than the default port (e.g. 8888).
- Enable simpletest.
- Use
run-tests.sh
to run a web test against this site, e.g.:
php ./core/scripts/run-tests.sh --verbose --url "http://localhost:8888/d8git" --class "Drupal\block\Tests\BlockTest"
- Observe that the test will fail, and the verbose output indicates that the URL used does not include the port:
Fatal error: Call to a member function label() on a non-object in /Applications/MAMP/htdocs/d8git/core/modules/block/lib/Drupal/block/Tests/BlockTest.php on line 115 FATAL Drupal\block\Tests\BlockTest: test runner returned a non-zero error code (255). - Found database prefix 'simpletest600546' for test ID 1. [04-Dec-2013 19:52:56 Europe/Berlin] PHP Fatal error: Call to a member function label() on a non-object in /Applications/MAMP/htdocs/d8git/core/modules/block/lib/Drupal/block/Tests/BlockTest.php on line 115 - Removed test files directory. - Removed 27 leftover tables. Test run duration: 28 sec Detailed test results --------------------- ---- Drupal\block\Tests\BlockTest ---- Status Group Filename Line Function -------------------------------------------------------------------------------- Pass Other BlockTestBase.php 39 Drupal\block\Tests\BlockTestBase->s Enabled modules: block, test_page_test Pass Role BlockTestBase.php 58 Drupal\block\Tests\BlockTestBase->s Created role ID 'zigskdoy' with name 'Wf"gM~K:'. Pass Role BlockTestBase.php 58 Drupal\block\Tests\BlockTestBase->s Created permissions: administer blocks, use text format full_html, access administration pages Pass User login BlockTestBase.php 58 Drupal\block\Tests\BlockTestBase->s User created with name cwe6TGAt and pass yJXnCbvPhQ Fail Browser BlockTestBase.php 59 Drupal\block\Tests\BlockTestBase->s GET http://localhost/d8git/user returned 0 (0 bytes).
Proposed resolution
Restore support for ports in URL generation.
Remaining tasks
TBD
API changes
TBD
Comment | File | Size | Author |
---|---|---|---|
#1 | correctly_set_server_port-2149977-1.patch | 1.19 KB | JStanton |
Comments
Comment #1
JStanton CreditAttribution: JStanton commentedrun-tests.sh wasn't correctly setting the $_SERVER['SERVER_PORT'] global.
Comment #3
JStanton CreditAttribution: JStanton commented1: correctly_set_server_port-2149977-1.patch queued for re-testing.
Comment #4
xjmTested locally with the STR from the summary and it resolves the issue. Patch looks fine; bot hiccup will presumably go away once the retest completes. Nicely done!
Comment #5
xjmComment #6
webchickToo bad we can't write tests for this. :)
Committed and pushed to 8.x. Thanks!