function UnroutedUrlAssemblerTest::setupRequestStack

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php \Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest::setupRequestStack()
  2. 10 core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php \Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest::setupRequestStack()
  3. 9 core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php \Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest::setupRequestStack()
  4. 8.9.x core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php \Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest::setupRequestStack()

Setups the request stack for a given subdir.

Parameters

bool $subdir: TRUE to use a subdir.

6 calls to UnroutedUrlAssemblerTest::setupRequestStack()
UnroutedUrlAssemblerTest::testAssembleExternalUrls in core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
Tests external URLs are only processed if necessary.
UnroutedUrlAssemblerTest::testAssembleWithEnabledProcessing in core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
Tests assemble with enabled processing.
UnroutedUrlAssemblerTest::testAssembleWithExternalUrl in core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
Tests assemble with external url.
UnroutedUrlAssemblerTest::testAssembleWithLocalUri in core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
Tests assemble with local uri.
UnroutedUrlAssemblerTest::testAssembleWithNotEnabledProcessing in core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
Tests assemble with not enabled processing.

... See full list

File

core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php, line 248

Class

UnroutedUrlAssemblerTest
Tests Drupal\Core\Utility\UnroutedUrlAssembler.

Namespace

Drupal\Tests\Core\Utility

Code

protected function setupRequestStack($subdir) : void {
  $server = [];
  if ($subdir) {
    // Setup a fake request which looks like a Drupal installed under the
    // subdir "subdir" on the domain www.example.com.
    // To reproduce the values install Drupal like that and use a debugger.
    $server = [
      'SCRIPT_NAME' => '/subdir/index.php',
      'SCRIPT_FILENAME' => $this->root . '/index.php',
      'SERVER_NAME' => 'www.example.com',
    ];
    $request = Request::create('/subdir/');
  }
  else {
    $request = Request::create('/');
  }
  $request->server
    ->add($server);
  $this->requestStack
    ->push($request);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.