Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / language / tests / src / Kernel / Migrate / d6 / MigrateLanguageContentMenuSettingsTest.php
1 <?php
2
3 namespace Drupal\Tests\language\Kernel\Migrate\d6;
4
5 use Drupal\language\Entity\ConfigurableLanguage;
6 use Drupal\language\Entity\ContentLanguageSettings;
7 use Drupal\Core\Language\LanguageInterface;
8 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
9
10 /**
11  * Tests migration of the ability to translate menu content.
12  *
13  * @group migrate_drupal_6
14  */
15 class MigrateLanguageContentMenuSettingsTest extends MigrateDrupal6TestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = [
21     'language',
22     'content_translation',
23     'menu_link_content',
24   ];
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUp() {
30     parent::setUp();
31     // Create some languages.
32     ConfigurableLanguage::createFromLangcode('en')->save();
33     ConfigurableLanguage::createFromLangcode('fr')->save();
34     $this->executeMigrations(['d6_language_content_menu_settings']);
35   }
36
37   /**
38    * Tests migration of menu translation ability.
39    */
40   public function testLanguageMenuContent() {
41     $config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
42     $this->assertInstanceOf(ContentLanguageSettings::class, $config);
43     $this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
44     $this->assertSame('menu_link_content', $config->getTargetBundle());
45     $this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
46     $this->assertTrue($config->isLanguageAlterable());
47
48     // Test that menus are not alterable when the i18nmenu is not enabled.
49     $this->sourceDatabase->update('system')
50       ->fields(['status' => 0])
51       ->condition('name', 'i18nmenu')
52       ->execute();
53
54     /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
55     $migration = $this->getMigration('d6_language_content_menu_settings');
56     // Indicate we're rerunning a migration that's already run.
57     $migration->getIdMap()->prepareUpdate();
58     $this->executeMigration($migration);
59
60     $config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
61     $this->assertInstanceOf(ContentLanguageSettings::class, $config);
62     $this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
63     $this->assertSame('menu_link_content', $config->getTargetBundle());
64     $this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
65     $this->assertFalse($config->isLanguageAlterable());
66   }
67
68 }