Issue #3440424 by alexpott: Inconsistent behaviour with drupalGet() when site is installed in a subdirectory
parent
54da986560
commit
39d743b8f1
|
@ -11,6 +11,7 @@ use Drupal\Core\Url;
|
||||||
use Drupal\Tests\BrowserTestBase;
|
use Drupal\Tests\BrowserTestBase;
|
||||||
use Drupal\Tests\StreamCapturer;
|
use Drupal\Tests\StreamCapturer;
|
||||||
use Drupal\Tests\Traits\Core\CronRunTrait;
|
use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||||
|
use Drupal\Tests\Traits\Core\PathAliasTestTrait;
|
||||||
use Drupal\user\Entity\Role;
|
use Drupal\user\Entity\Role;
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
@ -24,7 +25,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
* @group #slow
|
* @group #slow
|
||||||
*/
|
*/
|
||||||
class BrowserTestBaseTest extends BrowserTestBase {
|
class BrowserTestBaseTest extends BrowserTestBase {
|
||||||
|
use PathAliasTestTrait;
|
||||||
use CronRunTrait;
|
use CronRunTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,6 +124,19 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||||
$this->drupalGet('/test-page/');
|
$this->drupalGet('/test-page/');
|
||||||
$this->assertSession()->statusCodeEquals(200);
|
$this->assertSession()->statusCodeEquals(200);
|
||||||
$this->assertSession()->addressEquals('/test-page/');
|
$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/');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -301,6 +301,10 @@ trait UiHelperTrait {
|
||||||
if (substr($path, 0, $length) === $base_path) {
|
if (substr($path, 0, $length) === $base_path) {
|
||||||
$path = substr($path, $length);
|
$path = substr($path, $length);
|
||||||
}
|
}
|
||||||
|
// Additionally strip any forward slashes.
|
||||||
|
if (strlen($path) > 1) {
|
||||||
|
$path = ltrim($path, '/');
|
||||||
|
}
|
||||||
|
|
||||||
$force_internal = isset($options['external']) && $options['external'] == FALSE;
|
$force_internal = isset($options['external']) && $options['external'] == FALSE;
|
||||||
if (!$force_internal && UrlHelper::isExternal($path)) {
|
if (!$force_internal && UrlHelper::isExternal($path)) {
|
||||||
|
|
Loading…
Reference in New Issue