diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index 301aaa43cee326f62e7ad110df2c927346fa0ebd..ba576a6359b9b5117a0bd9ce3b7343f2782c2819 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -11,6 +11,7 @@ use Drupal\Tests\BrowserTestBase; use Drupal\Tests\StreamCapturer; use Drupal\Tests\Traits\Core\CronRunTrait; +use Drupal\Tests\Traits\Core\PathAliasTestTrait; use Drupal\user\Entity\Role; use PHPUnit\Framework\ExpectationFailedException; use Symfony\Component\HttpFoundation\Request; @@ -24,7 +25,7 @@ * @group #slow */ class BrowserTestBaseTest extends BrowserTestBase { - + use PathAliasTestTrait; use CronRunTrait; /** @@ -123,6 +124,19 @@ public function testDrupalGet() { $this->drupalGet('/test-page/'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('/test-page/'); + // Test alias handling. + $this->createPathAlias('/test-page', '/test-alias'); + $this->rebuildAll(); + $this->drupalGet('test-page'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->addressEquals('test-alias'); + $this->drupalGet('/test-page'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->addressEquals('test-alias'); + $this->drupalGet('/test-page/'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->addressEquals('/test-page/'); + } /** diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php index bcf5af79192b2d79fb6e7afb6dc547d53f1d29cb..71d6bc97b8fac4081a61c3b04029a55256d0993f 100644 --- a/core/tests/Drupal/Tests/UiHelperTrait.php +++ b/core/tests/Drupal/Tests/UiHelperTrait.php @@ -301,6 +301,10 @@ protected function buildUrl($path, array $options = []) { if (substr($path, 0, $length) === $base_path) { $path = substr($path, $length); } + // Additionally strip any forward slashes. + if (strlen($path) > 1) { + $path = ltrim($path, '/'); + } $force_internal = isset($options['external']) && $options['external'] == FALSE; if (!$force_internal && UrlHelper::isExternal($path)) {