1<?php 2 3namespace Drupal\Tests\language\Unit; 4 5use Drupal\language\Entity\ConfigurableLanguage; 6use Drupal\Tests\UnitTestCase; 7 8/** 9 * Tests the ConfigurableLanguage entity class. 10 * 11 * @group language 12 * @coversDefaultClass \Drupal\language\Entity\ConfigurableLanguage 13 * @see \Drupal\language\Entity\ConfigurableLanguage. 14 */ 15class ConfigurableLanguageUnitTest extends UnitTestCase { 16 17 /** 18 * @covers ::getDirection 19 */ 20 public function testDirection() { 21 // Direction of language writing, an integer. Usually either 22 // ConfigurableLanguage::DIRECTION_LTR or 23 // ConfigurableLanguage::DIRECTION_RTL. 24 $configurableLanguage = new ConfigurableLanguage(['direction' => ConfigurableLanguage::DIRECTION_LTR], 'configurable_language'); 25 $this->assertEquals(ConfigurableLanguage::DIRECTION_LTR, $configurableLanguage->getDirection()); 26 27 // Test direction again, setting direction to RTL. 28 $configurableLanguage = new ConfigurableLanguage(['direction' => ConfigurableLanguage::DIRECTION_RTL], 'configurable_language'); 29 $this->assertEquals(ConfigurableLanguage::DIRECTION_RTL, $configurableLanguage->getDirection()); 30 } 31 32 /** 33 * @covers ::getWeight 34 * @covers ::setWeight 35 */ 36 public function testWeight() { 37 // The weight, an integer. Used to order languages with larger positive 38 // weights sinking items toward the bottom of lists. 39 $configurableLanguage = new ConfigurableLanguage(['weight' => -5], 'configurable_language'); 40 $this->assertEquals(-5, $configurableLanguage->getWeight()); 41 $this->assertEquals(13, $configurableLanguage->setWeight(13)->getWeight()); 42 } 43 44} 45