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;
/**
/**
* {@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}
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();
}
* @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
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());
}
}
$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);
}
}