If you are attempting to run test cases against a server where the port is not 80, drupalGet / drupalPost will fail. For example:

$ drush test-run --uri=http://localhost:8888/drupal7/ EnableDisableTestCase --methods=testEnableDisable

I took a look at #580530: Command to run simpletests and there doesn't seem to be anything specifically related to the URI in the commit, so I wonder if this is a deeper problem with the --uri option.

Comments

greg.1.anderson’s picture

Here's the relevant code in environment.inc:

    $drupal_base_url = parse_url($drush_uri);
    // If there's no url scheme set, add http:// and re-parse the url
    // so the host and path values are set accurately.
    if (!array_key_exists('scheme', $drupal_base_url)) {
      $drush_uri = 'http://' . $drush_uri;
      $drupal_base_url = parse_url($drush_uri);
    }
    // Fill in defaults.
    $drupal_base_url += array(
      'path' => NULL,
      'host' => NULL,
    );
    $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
    if (array_key_exists('path', $drupal_base_url)) {
      $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
    }
    else {
      $_SERVER['PHP_SELF'] = '/index.php';
    }

As you can see, the port component from parse_url is not considered. It should be fairly easy to put it in; patches welcome.

deviantintegral’s picture

Status: Active » Needs review
StatusFileSize
new695 bytes

Thanks for the pointer; saved me digging it out myself.

Here's a patch.

deviantintegral’s picture

StatusFileSize
new1 KB

Reroll against master.

moshe weitzman’s picture

Code looks good. Needs documenting somewhere?

deviantintegral’s picture

StatusFileSize
new2.6 KB

This adds a commit that shows setting the port in the --uri option. I also added the issue number to the commit messages.

moshe weitzman’s picture

Assigned: Unassigned » msonnabaum
Status: Needs review » Patch (to be ported)

committed to master. I rebased these to a single commit. use 77426f79ceae17856b572a7c03ed04e6f4c4f908 for cherry pick to 4.x

msonnabaum’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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