function ContentEntityBaseUnitTest::setUpMockLanguageManager
Reinitializes the language manager as a mock object.
1 call to ContentEntityBaseUnitTest::setUpMockLanguageManager()
- ContentEntityBaseUnitTest::testIsTranslatable in core/
tests/ Drupal/ Tests/ Core/ Entity/ ContentEntityBaseUnitTest.php - Tests is translatable.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ ContentEntityBaseUnitTest.php, line 254
Class
Namespace
Drupal\Tests\Core\EntityCode
protected function setUpMockLanguageManager() : void {
$english = new Language([
'id' => 'en',
]);
$not_specified = new Language([
'id' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'locked' => TRUE,
]);
$this->languageManager = $this->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
$this->languageManager
->method('getLanguages')
->willReturn([
'en' => $english,
LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified,
]);
$this->languageManager
->method('getLanguage')
->with('en')
->willReturn($english);
$this->languageManager
->method('getLanguage')
->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
->willReturn($not_specified);
\Drupal::getContainer()->set('language_manager', $this->languageManager);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.