Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / menu_link_content / tests / src / Kernel / Migrate / d7 / MigrateMenuLinkTest.php
index a5e8dd0e705e929ee45e6c4088047c110ac8fdd9..e9913f6fa65d054d5ad16b2229ad88fc930a5bcb 100644 (file)
@@ -5,7 +5,6 @@ namespace Drupal\Tests\menu_link_content\Kernel\Migrate\d7;
 use Drupal\Core\Menu\MenuTreeParameters;
 use Drupal\menu_link_content\Entity\MenuLinkContent;
 use Drupal\menu_link_content\MenuLinkContentInterface;
-use Drupal\node\Entity\Node;
 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
 
 /**
@@ -19,7 +18,17 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
   /**
    * {@inheritdoc}
    */
-  public static $modules = ['link', 'menu_ui', 'menu_link_content', 'node'];
+  public static $modules = [
+    'content_translation',
+    'language',
+    'link',
+    'menu_ui',
+    'menu_link_content',
+    // Required for translation migrations.
+    'migrate_drupal_multilingual',
+    'node',
+    'text',
+  ];
 
   /**
    * {@inheritdoc}
@@ -28,13 +37,20 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
     parent::setUp();
     $this->installEntitySchema('menu_link_content');
     $this->installEntitySchema('node');
-    $node = Node::create([
-      'nid' => 2,
-      'title' => 'node link test',
-      'type' => 'article',
+    $this->installSchema('node', ['node_access']);
+    $this->installConfig(static::$modules);
+    $this->executeMigrations([
+      'language',
+      'd7_user_role',
+      'd7_user',
+      'd7_node_type',
+      'd7_language_content_settings',
+      'd7_node',
+      'd7_node_translation',
+      'd7_menu',
+      'd7_menu_links',
+      'node_translation_menu_links',
     ]);
-    $node->save();
-    $this->executeMigrations(['d7_menu', 'd7_menu_links']);
     \Drupal::service('router.builder')->rebuild();
   }
 
@@ -52,7 +68,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
    * @param bool $enabled
    *   Whether the link is enabled.
    * @param bool $expanded
-   *   Whether the link is expanded
+   *   Whether the link is expanded.
    * @param array $attributes
    *   Additional attributes the link is expected to have.
    * @param string $uri
@@ -66,11 +82,9 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
   protected function assertEntity($id, $title, $menu, $description, $enabled, $expanded, array $attributes, $uri, $weight) {
     /** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link */
     $menu_link = MenuLinkContent::load($id);
-    $this->assertTrue($menu_link instanceof MenuLinkContentInterface);
+    $this->assertInstanceOf(MenuLinkContentInterface::class, $menu_link);
     $this->assertSame($title, $menu_link->getTitle());
     $this->assertSame($menu, $menu_link->getMenuName());
-    // The migration sets the description of the link to the value of the
-    // 'title' attribute. Bit strange, but there you go.
     $this->assertSame($description, $menu_link->getDescription());
     $this->assertSame($enabled, $menu_link->isEnabled());
     $this->assertSame($expanded, $menu_link->isExpanded());
@@ -120,6 +134,12 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
       }
     }
     $this->assertTrue($found);
+
+    // Test the migration of menu links for translated nodes.
+    $this->assertEntity(484, 'The thing about Deep Space 9', 'tools', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'entity:node/2', 9);
+    $this->assertEntity(485, 'is - The thing about Deep Space 9', 'tools', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'entity:node/2', 10);
+    $this->assertEntity(486, 'is - The thing about Firefly', 'tools', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'entity:node/4', 11);
+    $this->assertEntity(487, 'en - The thing about Firefly', 'tools', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'entity:node/4', 12);
   }
 
 }