3 namespace Drupal\Tests\language\Unit;
5 use Drupal\language\Entity\ConfigurableLanguage;
6 use Drupal\Tests\UnitTestCase;
9 * Tests the ConfigurableLanguage entity class.
12 * @coversDefaultClass \Drupal\language\Entity\ConfigurableLanguage
13 * @see \Drupal\language\Entity\ConfigurableLanguage.
15 class ConfigurableLanguageUnitTest extends UnitTestCase {
18 * @covers ::getDirection
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());
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());
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($configurableLanguage->getWeight(), -5);
41 $this->assertEquals($configurableLanguage->setWeight(13)->getWeight(), 13);