diff --git a/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php b/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php index 0b55d7c..7c945f7 100644 --- a/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php +++ b/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php @@ -8,6 +8,7 @@ namespace Drupal\menu_link_content\Tests\Migrate\d7; use Drupal\Core\Database\Database; +use Drupal\Core\Menu\MenuTreeParameters; use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\menu_link_content\MenuLinkContentInterface; use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase; @@ -18,6 +19,7 @@ * @group menu_link_content */ class MigrateMenuLinkTest extends MigrateDrupal7TestBase { + const MENU_NAME = 'menu-test-menu'; /** * {@inheritdoc} @@ -57,7 +59,7 @@ protected function setUp() { * @param int $weight * The expected weight of the link. */ - protected function assertEntity($id, $title, $menu, $description, $enabled, $expanded, array $attributes, $uri, $weight, $parent = '') { + 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); @@ -71,9 +73,6 @@ protected function assertEntity($id, $title, $menu, $description, $enabled, $exp $this->assertIdentical($attributes, $menu_link->link->options); $this->assertIdentical($uri, $menu_link->link->uri); $this->assertIdentical($weight, $menu_link->getWeight()); - if ($parent) { - $this->assertIdentical($parent, $menu_link->getParentId()); - } return $menu_link; } @@ -82,9 +81,19 @@ protected function assertEntity($id, $title, $menu, $description, $enabled, $exp */ public function testMenuLinks() { $this->executeMigration('d7_menu_links'); - $menu_link = $this->assertEntity(469, 'Bing', 'menu-test-menu', 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0); - $this->assertEntity(467, 'Google', 'menu-test-menu', 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0, $menu_link->getPluginId()); - $this->assertEntity(468, 'Yahoo', 'menu-test-menu', 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0); + $this->assertEntity(469, 'Bing', static::MENU_NAME, 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0); + $this->assertEntity(467, 'Google', static::MENU_NAME, 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0); + $this->assertEntity(468, 'Yahoo', static::MENU_NAME, 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0); + $tree = \Drupal::service('menu.link_tree')->load(static::MENU_NAME, new MenuTreeParameters()); + $this->assertEqual(2, count($tree)); + $children = 0; + foreach ($tree as $menu_link_tree_element) { + $children += $menu_link_tree_element->hasChildren; + if ($menu_link_tree_element->link->getUrlObject()->toString() == 'http://bing.com') { + $this->assertEqual(reset($menu_link_tree_element->subtree)->link->getUrlObject()->toString(), 'http://google.com'); + } + } + $this->assertEqual(1, $children); } /** @@ -100,7 +109,7 @@ public function testUndefinedLinkTitle() { ->execute(); $this->executeMigration('d7_menu_links'); - $this->assertEntity(467, 'Google', 'menu-test-menu', NULL, TRUE, FALSE, [], 'http://google.com', 0); + $this->assertEntity(467, 'Google', static::MENU_NAME, NULL, TRUE, FALSE, [], 'http://google.com', 0); } }