function UiHelperTrait::getAbsoluteUrl
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::getAbsoluteUrl()
- 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::getAbsoluteUrl()
- 11.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::getAbsoluteUrl()
Takes a path and returns an absolute path.
Parameters
string $path: A path from the Mink controlled browser content.
Return value
string The $path with $base_url prepended, if necessary.
11 calls to UiHelperTrait::getAbsoluteUrl()
- BlockTest::testAddBlockFromLibraryWithWeight in core/
modules/ block/ tests/ src/ Functional/ BlockTest.php - Tests adding a block from the library page with a weight query string.
- CommentPagerTest::clickLinkWithXPath in core/
modules/ comment/ tests/ src/ Functional/ CommentPagerTest.php - Follows a link found at a give xpath query.
- ConfigInstallWebTest::testPreExistingConfigInstall in core/
modules/ config/ tests/ src/ Functional/ ConfigInstallWebTest.php - Tests pre-existing configuration detection.
- ConvertTest::testConvertFileInRoot in core/
modules/ image/ tests/ src/ Functional/ ImageEffect/ ConvertTest.php - Tests that files stored in the root folder are converted properly.
- EntityReferenceAdminTest::testFieldAdminHandler in core/
modules/ field/ tests/ src/ Functional/ EntityReference/ EntityReferenceAdminTest.php - Tests the Entity Reference Admin UI.
File
-
core/
tests/ Drupal/ Tests/ UiHelperTrait.php, line 409
Class
- UiHelperTrait
- Provides UI helper methods.
Namespace
Drupal\TestsCode
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 (empty($path) || $path[0] !== '/') {
$path = '/' . $path;
}
// Finally, prepend the $base_url.
$path = $base_url . $path;
}
return $path;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.