protected function DrupalWebTestCase::getAbsoluteUrl in SimpleTest 7.2
Same name and namespace in other branches
- 6.2 drupal_web_test_case.php \DrupalWebTestCase::getAbsoluteUrl()
- 7 drupal_web_test_case.php \DrupalWebTestCase::getAbsoluteUrl()
Takes a path and returns an absolute path.
Parameters
$path: A path from the internal browser content.
Return value
The $path with $base_url prepended, if necessary.
4 calls to DrupalWebTestCase::getAbsoluteUrl()
- DrupalWebTestCase::checkForMetaRefresh in ./
drupal_web_test_case.php - Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
- DrupalWebTestCase::clickLink in ./
drupal_web_test_case.php - Follows a link by name.
- DrupalWebTestCase::drupalPost in ./
drupal_web_test_case.php - Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
- SimpleTestURLTestCase::testGetAbsoluteUrl in ./
simpletest.test - Test DrupalWebTestCase::getAbsoluteUrl().
File
- ./
drupal_web_test_case.php, line 2514 - Provides DrupalTestCase, DrupalUnitTestCase, and DrupalWebTestCase classes.
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
Code
protected function getAbsoluteUrl($path) {
global $base_url, $base_path;
$parts = parse_url($path);
if (empty($parts['host'])) {
// Ensure that we have a string (and no xpath object).
$path = (string) $path;
// Strip $base_path, if existent.
$length = strlen($base_path);
if (substr($path, 0, $length) === $base_path) {
$path = substr($path, $length);
}
// Ensure that we have an absolute path.
if ($path[0] !== '/') {
$path = '/' . $path;
}
// Finally, prepend the $base_url.
$path = $base_url . $path;
}
return $path;
}