function LanguageNegotiationUrlTest::setUp
Same name in this branch
- 9 core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Functional\LanguageNegotiationUrlTest::setUp()
Same name in other branches
- 8.9.x core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Unit\LanguageNegotiationUrlTest::setUp()
- 8.9.x core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Functional\LanguageNegotiationUrlTest::setUp()
- 10 core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Unit\LanguageNegotiationUrlTest::setUp()
- 10 core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Functional\LanguageNegotiationUrlTest::setUp()
- 11.x core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Unit\LanguageNegotiationUrlTest::setUp()
- 11.x core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Functional\LanguageNegotiationUrlTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
modules/ language/ tests/ src/ Unit/ LanguageNegotiationUrlTest.php, line 26
Class
- LanguageNegotiationUrlTest
- @coversDefaultClass \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl @group language
Namespace
Drupal\Tests\language\UnitCode
protected function setUp() : void {
// Set up some languages to be used by the language-based path processor.
$language_de = $this->createMock('\\Drupal\\Core\\Language\\LanguageInterface');
$language_de->expects($this->any())
->method('getId')
->willReturn('de');
$language_en = $this->createMock('\\Drupal\\Core\\Language\\LanguageInterface');
$language_en->expects($this->any())
->method('getId')
->willReturn('en');
$languages = [
'de' => $language_de,
'en' => $language_en,
];
$this->languages = $languages;
// Create a language manager stub.
$language_manager = $this->getMockBuilder('Drupal\\language\\ConfigurableLanguageManagerInterface')
->getMock();
$language_manager->expects($this->any())
->method('getLanguages')
->willReturn($languages);
$this->languageManager = $language_manager;
// Create a user stub.
$this->user = $this->getMockBuilder('Drupal\\Core\\Session\\AccountInterface')
->getMock();
$cache_contexts_manager = $this->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager->method('assertValidTokens')
->willReturn(TRUE);
$container = new ContainerBuilder();
$container->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.