You are here

public function LanguageUnitTest::testConstruct in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testConstruct()
  2. 10 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testConstruct()

@covers ::__construct

File

core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php, line 18

Class

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

Namespace

Drupal\Tests\Core\Language

Code

public function testConstruct() {
  $name = $this
    ->randomMachineName();
  $language_code = $this
    ->randomMachineName(2);
  $uuid = $this
    ->randomMachineName();
  $language = new Language([
    'id' => $language_code,
    'name' => $name,
    'uuid' => $uuid,
  ]);

  // Test that nonexistent properties are not added to the language object.
  $this
    ->assertTrue(property_exists($language, 'id'));
  $this
    ->assertTrue(property_exists($language, 'name'));
  $this
    ->assertFalse(property_exists($language, 'uuid'));
}