Version 1
[yaffs-website] / web / core / modules / language / tests / src / Functional / Migrate / MigrateLanguageTest.php
1 <?php
2
3 namespace Drupal\Tests\language\Functional\Migrate;
4
5 use Drupal\language\ConfigurableLanguageInterface;
6 use Drupal\language\Entity\ConfigurableLanguage;
7 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
8
9 /**
10  * @group migrate_drupal_6
11  */
12 class MigrateLanguageTest extends MigrateDrupal6TestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['language'];
18
19   /**
20    * Asserts various properties of a configurable language entity.
21    *
22    * @param string $id
23    *   The language ID.
24    * @param string $label
25    *   The language name.
26    * @param string $direction
27    *   (optional) The language's direction (one of the DIRECTION_* constants in
28    *   ConfigurableLanguageInterface). Defaults to LTR.
29    * @param int $weight
30    *   (optional) The weight of the language. Defaults to 0.
31    */
32   protected function assertLanguage($id, $label, $direction = ConfigurableLanguageInterface::DIRECTION_LTR, $weight = 0) {
33     /** @var \Drupal\language\ConfigurableLanguageInterface $language */
34     $language = ConfigurableLanguage::load($id);
35     $this->assertTrue($language instanceof ConfigurableLanguageInterface);
36     $this->assertIdentical($label, $language->label());
37     $this->assertIdentical($direction, $language->getDirection());
38     $this->assertIdentical(0, $language->getWeight());
39     $this->assertFalse($language->isLocked());
40   }
41
42   /**
43    * Tests migration of Drupal 6 languages to configurable language entities.
44    */
45   public function testLanguageMigration() {
46     $this->executeMigration('language');
47     $this->assertLanguage('en', 'English');
48     $this->assertLanguage('fr', 'French');
49   }
50
51 }