You are here

public function LanguageUnitTest::testIsDefault in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 65
Contains \Drupal\Tests\Core\Language\LanguageUnitTest.

Class

LanguageUnitTest
@coversDefaultClass \Drupal\Core\Language\Language @group Language

Namespace

Drupal\Tests\Core\Language

Code

public function testIsDefault() {
  $language_default = $this
    ->getMockBuilder('Drupal\\Core\\Language\\LanguageDefault')
    ->disableOriginalConstructor()
    ->getMock();
  $container = $this
    ->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
  $container
    ->expects($this
    ->any())
    ->method('get')
    ->with('language.default')
    ->will($this
    ->returnValue($language_default));
  \Drupal::setContainer($container);
  $language = new Language(array(
    '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(array(
    'id' => $this
      ->randomMachineName(2),
  )));
  $this
    ->assertTrue($language
    ->isDefault());
  $this
    ->assertFalse($language
    ->isDefault());
}