function LanguageUnitTest::testIsDefault
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testIsDefault()
- 10 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testIsDefault()
- 11.x core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testIsDefault()
@covers ::isDefault
File
-
core/
tests/ Drupal/ Tests/ Core/ Language/ LanguageUnitTest.php, line 60
Class
- LanguageUnitTest
- @coversDefaultClass \Drupal\Core\Language\Language @group Language
Namespace
Drupal\Tests\Core\LanguageCode
public function testIsDefault() {
$language_default = $this->getMockBuilder('Drupal\\Core\\Language\\LanguageDefault')
->disableOriginalConstructor()
->getMock();
$container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$container->expects($this->any())
->method('get')
->with('language.default')
->willReturn($language_default);
\Drupal::setContainer($container);
$language = new Language([
'id' => $this->randomMachineName(2),
]);
// Set up the LanguageDefault to return different default languages on
// consecutive calls.
$language_default->expects($this->any())
->method('get')
->willReturnOnConsecutiveCalls($language, new Language([
'id' => $this->randomMachineName(2),
]));
$this->assertTrue($language->isDefault());
$this->assertFalse($language->isDefault());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.