function LanguageUnitTest::testConstruct

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testConstruct()
  2. 8.9.x core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::testConstruct()
  3. 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 20

Class

LanguageUnitTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Language%21Language.php/class/Language/11.x" title="An object containing the information for an interface language." class="local">\Drupal\Core\Language\Language</a> @group Language

Namespace

Drupal\Tests\Core\Language

Code

public function testConstruct() : void {
    $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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.