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

  1. Install Drupal to run on a port other than the default port (e.g. 8888).
  2. Enable simpletest.
  3. 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"
    
  4. 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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JStanton’s picture

Status: Active » Needs review
FileSize
1.19 KB

run-tests.sh wasn't correctly setting the $_SERVER['SERVER_PORT'] global.

Status: Needs review » Needs work

The last submitted patch, 1: correctly_set_server_port-2149977-1.patch, failed testing.

JStanton’s picture

Status: Needs work » Needs review
xjm’s picture

Status: Needs review » Reviewed & tested by the community

Tested 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!

xjm’s picture

Component: request processing system » base system
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Too bad we can't write tests for this. :)

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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