You are here

protected function PathProcessorTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 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 38

Class

PathProcessorTest
Tests processing of the inbound path.

Namespace

Drupal\Tests\Core\PathProcessor

Code

protected function setUp() {

  // 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')
    ->will($this
    ->returnValue($languages['en']));
  $language_manager
    ->expects($this
    ->any())
    ->method('getLanguages')
    ->will($this
    ->returnValue($this->languages));
  $language_manager
    ->expects($this
    ->any())
    ->method('getLanguageTypes')
    ->will($this
    ->returnValue([
    LanguageInterface::TYPE_INTERFACE,
  ]));
  $this->languageManager = $language_manager;
}