function PathProcessorTest::setUp

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php \Drupal\Tests\Core\PathProcessor\PathProcessorTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php \Drupal\Tests\Core\PathProcessor\PathProcessorTest::setUp()
  3. 11.x core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php \Drupal\Tests\Core\PathProcessor\PathProcessorTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php, line 41

Class

PathProcessorTest
Tests processing of the inbound path.

Namespace

Drupal\Tests\Core\PathProcessor

Code

protected function setUp() : void {
    // Set up some languages to be used by the language-based path processor.
    $languages = [];
    foreach ([
        'en',
        'fr',
    ] as $langcode) {
        $language = new Language([
            'id' => $langcode,
        ]);
        $languages[$langcode] = $language;
    }
    $this->languages = $languages;
    // Create a stub configuration.
    $language_prefixes = array_keys($this->languages);
    $config = [
        'url' => [
            'prefixes' => array_combine($language_prefixes, $language_prefixes),
        ],
    ];
    // Create a language manager stub.
    $language_manager = $this->getMockBuilder('Drupal\\language\\ConfigurableLanguageManagerInterface')
        ->getMock();
    $language_manager->expects($this->any())
        ->method('getCurrentLanguage')
        ->willReturn($languages['en']);
    $language_manager->expects($this->any())
        ->method('getLanguages')
        ->willReturn($this->languages);
    $language_manager->expects($this->any())
        ->method('getLanguageTypes')
        ->willReturn([
        LanguageInterface::TYPE_INTERFACE,
    ]);
    $this->languageManager = $language_manager;
}

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