ConfigurableLanguage example


  protected static $modules = ['language'];

  /** * Tests configurable language name methods. */
  public function testName() {
    $name = $this->randomMachineName();
    $language_code = $this->randomMachineName(2);
    $configurableLanguage = new ConfigurableLanguage(['label' => $name, 'id' => $language_code], 'configurable_language');
    $this->assertEquals($name$configurableLanguage->getName());
    $this->assertEquals('Test language', $configurableLanguage->setName('Test language')->getName());
  }

}

class ConfigurableLanguageUnitTest extends UnitTestCase {

  /** * @covers ::getDirection */
  public function testDirection() {
    // Direction of language writing, an integer. Usually either     // ConfigurableLanguage::DIRECTION_LTR or     // ConfigurableLanguage::DIRECTION_RTL.     $configurableLanguage = new ConfigurableLanguage(['direction' => ConfigurableLanguage::DIRECTION_LTR], 'configurable_language');
    $this->assertEquals(ConfigurableLanguage::DIRECTION_LTR, $configurableLanguage->getDirection());

    // Test direction again, setting direction to RTL.     $configurableLanguage = new ConfigurableLanguage(['direction' => ConfigurableLanguage::DIRECTION_RTL], 'configurable_language');
    $this->assertEquals(ConfigurableLanguage::DIRECTION_RTL, $configurableLanguage->getDirection());
  }

  /** * @covers ::getWeight * @covers ::setWeight */
  
Home | Imprint | This part of the site doesn't use cookies.