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 fbc0c7d08d84fdd0d81479198f975429f7856da1..0049480c19cbdc3e25c1968164d5d8e6608a42eb 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 4d46739c33696113c9a76db39256a8c086149866..4e30b9241acd30d0eecd76417f642da3a6f9a927 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); + } + }