public function LanguageUnitTest::testIsDefault in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testIsDefault()
- 9 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')
->will($this
->returnValue($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());
}