From 3e3a20744368f22e6b3fbe1ce16a9ac75ba37c8c Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Thu, 3 Sep 2015 10:01:37 -0700 Subject: [PATCH] Issue #2562075 by phenaproxima: D7 menu link migration must provide a default description --- .../migration_templates/d7_menu_links.yml | 1 + .../Tests/Migrate/d7/MigrateMenuLinkTest.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/modules/menu_link_content/migration_templates/d7_menu_links.yml b/core/modules/menu_link_content/migration_templates/d7_menu_links.yml index fbc0c7d08d84..0049480c19cb 100644 --- a/core/modules/menu_link_content/migration_templates/d7_menu_links.yml +++ b/core/modules/menu_link_content/migration_templates/d7_menu_links.yml @@ -18,6 +18,7 @@ process: - 0 - attributes - title + default: '' menu_name: plugin: migration migration: menu 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 4d46739c3369..4e30b9241acd 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 @@ -7,6 +7,7 @@ namespace Drupal\menu_link_content\Tests\Migrate\d7; +use Drupal\Core\Database\Database; use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\menu_link_content\MenuLinkContentInterface; use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase; @@ -33,7 +34,6 @@ protected function setUp() { $this->installSchema('system', ['router']); $this->installEntitySchema('menu_link_content'); $this->executeMigration('menu'); - $this->executeMigration('d7_menu_links'); } /** @@ -78,9 +78,26 @@ protected function assertEntity($id, $title, $menu, $description, $enabled, $exp * Tests migration of menu links. */ public function testMenuLinks() { + $this->executeMigration('d7_menu_links'); $this->assertEntity(467, 'Google', 'menu-test-menu', 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0); $this->assertEntity(468, 'Yahoo', 'menu-test-menu', 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0); $this->assertEntity(469, 'Bing', 'menu-test-menu', 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0); } + /** + * Tests migrating a link with an undefined title attribute. + */ + public function testUndefinedLinkTitle() { + Database::getConnection('default', 'migrate') + ->update('menu_links') + ->fields(array( + 'options' => 'a:0:{}', + )) + ->condition('mlid', 467) + ->execute(); + + $this->executeMigration('d7_menu_links'); + $this->assertEntity(467, 'Google', 'menu-test-menu', NULL, TRUE, FALSE, [], 'http://google.com', 0); + } + } -- GitLab