Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
8d783b7c
Commit
8d783b7c
authored
Oct 28, 2016
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2669978
by Jo Fitzgerald, arturs.v, phenaproxima: Migrate D7 Menu Links
parent
e2d04052
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
366 additions
and
56 deletions
+366
-56
core/modules/menu_link_content/migration_templates/d6_menu_links.yml
...s/menu_link_content/migration_templates/d6_menu_links.yml
+6
-4
core/modules/menu_link_content/migration_templates/d7_menu_links.yml
...s/menu_link_content/migration_templates/d7_menu_links.yml
+52
-0
core/modules/menu_link_content/src/Plugin/migrate/process/d7/InternalUri.php
...ink_content/src/Plugin/migrate/process/d7/InternalUri.php
+43
-0
core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php
...ntent/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php
+1
-1
core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
...ntent/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
+22
-31
core/modules/menu_link_content/tests/src/Unit/Plugin/migrate/process/d7/InternalUriTest.php
...ts/src/Unit/Plugin/migrate/process/d7/InternalUriTest.php
+73
-0
core/modules/migrate_drupal/tests/fixtures/drupal7.php
core/modules/migrate_drupal/tests/fixtures/drupal7.php
+54
-0
core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
...modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
+10
-2
core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php
...es/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php
+2
-2
core/modules/shortcut/migration_templates/d7_shortcut.yml
core/modules/shortcut/migration_templates/d7_shortcut.yml
+1
-1
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
...ut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
+2
-2
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php
...sts/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php
+2
-2
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
...rtcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
+2
-2
core/modules/system/migration_templates/d6_menu.yml
core/modules/system/migration_templates/d6_menu.yml
+1
-2
core/modules/system/migration_templates/d7_menu.yml
core/modules/system/migration_templates/d7_menu.yml
+20
-0
core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
...es/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
+7
-7
core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
...es/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
+68
-0
No files found.
core/modules/menu_link_content/migration_templates/menu_links.yml
→
core/modules/menu_link_content/migration_templates/
d6_
menu_links.yml
View file @
8d783b7c
id
:
menu_links
id
:
d6_
menu_links
label
:
Menu links
migration_tags
:
-
Drupal
6
-
Drupal
7
source
:
plugin
:
menu_link
process
:
...
...
@@ -13,8 +12,11 @@ process:
-
plugin
:
migration
# The menu migration is in the system module.
migration
:
menu
migration
:
d6_
menu
source
:
menu_name
-
plugin
:
skip_on_empty
method
:
row
-
plugin
:
static_map
map
:
...
...
@@ -51,4 +53,4 @@ destination:
no_stub
:
true
migration_dependencies
:
required
:
-
menu
-
d6_
menu
core/modules/menu_link_content/migration_templates/d7_menu_links.yml
0 → 100644
View file @
8d783b7c
id
:
d7_menu_links
label
:
Menu links
migration_tags
:
-
Drupal
7
source
:
plugin
:
menu_link
constants
:
bundle
:
menu_link_content
process
:
id
:
mlid
bundle
:
'
constants/bundle'
title
:
link_title
description
:
description
menu_name
:
-
plugin
:
migration
migration
:
d7_menu
source
:
menu_name
-
plugin
:
skip_on_empty
method
:
row
'
link/uri'
:
plugin
:
d7_internal_uri
source
:
-
link_path
'
link/options'
:
options
route
:
plugin
:
route
source
:
-
link_path
-
options
route_name
:
'
@route/route_name'
route_parameters
:
'
@route/route_parameters'
url
:
'
@route/url'
options
:
'
@route/options'
external
:
external
weight
:
weight
expanded
:
expanded
enabled
:
enabled
parent
:
plugin
:
menu_link_parent
source
:
-
plid
-
'
@menu_name'
-
parent_link_path
changed
:
updated
destination
:
plugin
:
entity:menu_link_content
no_stub
:
true
migration_dependencies
:
required
:
-
d7_menu
core/modules/menu_link_content/src/Plugin/migrate/process/d7/InternalUri.php
0 → 100644
View file @
8d783b7c
<?php
namespace
Drupal\menu_link_content\Plugin\migrate\process\d7
;
use
Drupal\migrate\MigrateExecutableInterface
;
use
Drupal\migrate\ProcessPluginBase
;
use
Drupal\migrate\Row
;
/**
* Process a path into an 'internal:' URI.
*
* @MigrateProcessPlugin(
* id = "d7_internal_uri"
* )
*/
class
InternalUri
extends
ProcessPluginBase
{
/**
* {@inheritdoc}
*/
public
function
transform
(
$value
,
MigrateExecutableInterface
$migrate_executable
,
Row
$row
,
$destination_property
)
{
list
(
$path
)
=
$value
;
$path
=
ltrim
(
$path
,
'/'
);
if
(
parse_url
(
$path
,
PHP_URL_SCHEME
)
==
NULL
)
{
// If $path is the node page (i.e. node/[nid]) then return entity path.
if
(
preg_match
(
'/^node\/\d+$/'
,
$path
))
{
// "entity: URI"s enable the menu link to appear in the Menu Settings
// section on the node edit page. Other entities (e.g. taxonomy terms,
// users) do not have the Menu Settings section.
return
'entity:'
.
$path
;
}
elseif
(
$path
==
'<front>'
)
{
return
'internal:/'
;
}
else
{
return
'internal:/'
.
$path
;
}
}
return
$path
;
}
}
core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php
View file @
8d783b7c
...
...
@@ -23,7 +23,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
installEntitySchema
(
'menu_link_content'
);
$this
->
executeMigrations
([
'
menu'
,
'
menu_links'
]);
$this
->
executeMigrations
([
'
d6_menu'
,
'd6_
menu_links'
]);
}
/**
...
...
core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
View file @
8d783b7c
...
...
@@ -2,7 +2,6 @@
namespace
Drupal\Tests\menu_link_content\Kernel\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
;
...
...
@@ -27,7 +26,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
installEntitySchema
(
'menu_link_content'
);
$this
->
executeMigration
(
'menu'
);
$this
->
executeMigration
s
([
'd7_menu'
,
'd7_menu_links'
]
);
\
Drupal
::
service
(
'router.builder'
)
->
rebuild
();
}
...
...
@@ -52,21 +51,24 @@ protected function setUp() {
* The expected URI of the link.
* @param int $weight
* The expected weight of the link.
*
* @return \Drupal\menu_link_content\MenuLinkContentInterface
* The menu link content.
*/
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
->
assert
Identical
(
$title
,
$menu_link
->
getTitle
());
$this
->
assert
Identical
(
$menu
,
$menu_link
->
getMenuName
());
$this
->
assert
Same
(
$title
,
$menu_link
->
getTitle
());
$this
->
assert
Same
(
$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
->
assert
Identical
(
$description
,
$menu_link
->
getDescription
());
$this
->
assert
Identical
(
$enabled
,
$menu_link
->
isEnabled
());
$this
->
assert
Identical
(
$expanded
,
$menu_link
->
isExpanded
());
$this
->
assert
Identical
(
$attributes
,
$menu_link
->
link
->
options
);
$this
->
assert
Identical
(
$uri
,
$menu_link
->
link
->
uri
);
$this
->
assert
Identical
(
$weight
,
$menu_link
->
getWeight
());
$this
->
assert
Same
(
$description
,
$menu_link
->
getDescription
());
$this
->
assert
Same
(
$enabled
,
$menu_link
->
isEnabled
());
$this
->
assert
Same
(
$expanded
,
$menu_link
->
isExpanded
());
$this
->
assert
Same
(
$attributes
,
$menu_link
->
link
->
options
);
$this
->
assert
Same
(
$uri
,
$menu_link
->
link
->
uri
);
$this
->
assert
Same
(
$weight
,
$menu_link
->
getWeight
());
return
$menu_link
;
}
...
...
@@ -74,31 +76,36 @@ protected function assertEntity($id, $title, $menu, $description, $enabled, $exp
* Tests migration of menu links.
*/
public
function
testMenuLinks
()
{
$this
->
executeMigration
(
'menu_links'
);
$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
);
// Tests migrating an external link with an undefined title attribute.
$this
->
assertEntity
(
470
,
'Ask'
,
static
::
MENU_NAME
,
NULL
,
TRUE
,
FALSE
,
[],
'http://ask.com'
,
0
);
$this
->
assertEntity
(
245
,
'Home'
,
'main'
,
NULL
,
TRUE
,
FALSE
,
[],
'internal:/'
,
0
);
$this
->
assertEntity
(
478
,
'custom link test'
,
'admin'
,
NULL
,
TRUE
,
FALSE
,
[
'attributes'
=>
[
'title'
=>
''
]],
'internal:/admin/content/book'
,
0
);
$this
->
assertEntity
(
479
,
'node link test'
,
'tools'
,
'node 3'
,
TRUE
,
FALSE
,
[
'attributes'
=>
[
'title'
=>
'node 3'
]],
'entity:node/3'
,
3
);
$menu_link_tree_service
=
\
Drupal
::
service
(
'menu.link_tree'
);
$parameters
=
new
MenuTreeParameters
();
$tree
=
$menu_link_tree_service
->
load
(
static
::
MENU_NAME
,
$parameters
);
$this
->
assert
Equal
(
2
,
count
(
$tree
)
);
$this
->
assert
Count
(
2
,
$tree
);
$children
=
0
;
$google_found
=
FALSE
;
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
s
(
reset
(
$menu_link_tree_element
->
subtree
)
->
link
->
getUrlObject
()
->
toString
(),
'http://google.com'
);
$google_found
=
TRUE
;
}
}
$this
->
assertEqual
(
1
,
$children
);
$this
->
assertEqual
s
(
1
,
$children
);
$this
->
assertTrue
(
$google_found
);
// Now find the custom link under a system link.
$parameters
->
root
=
'system.admin_structure'
;
$tree
=
$menu_link_tree_service
->
load
(
static
::
MENU_NAME
,
$parameters
);
$found
=
FALSE
;
foreach
(
$tree
as
$menu_link_tree_element
)
{
$this
->
pass
(
$menu_link_tree_element
->
link
->
getUrlObject
()
->
toString
());
$this
->
assertTrue
(
$menu_link_tree_element
->
link
->
getUrlObject
()
->
toString
());
if
(
$menu_link_tree_element
->
link
->
getTitle
()
==
'custom link test'
)
{
$found
=
TRUE
;
break
;
...
...
@@ -107,20 +114,4 @@ public function testMenuLinks() {
$this
->
assertTrue
(
$found
);
}
/**
* 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
(
'menu_links'
);
$this
->
assertEntity
(
467
,
'Google'
,
static
::
MENU_NAME
,
NULL
,
TRUE
,
FALSE
,
[],
'http://google.com'
,
0
);
}
}
core/modules/menu_link_content/tests/src/Unit/Plugin/migrate/process/d7/InternalUriTest.php
0 → 100644
View file @
8d783b7c
<?php
namespace
Drupal\Tests\menu_link_content\Unit\Plugin\migrate\process\d7
;
use
Drupal\menu_link_content
\
Plugin\migrate\process\d7\InternalUri
;
use
Drupal\migrate\MigrateExecutableInterface
;
use
Drupal\migrate\Row
;
use
Drupal\Tests\UnitTestCase
;
/**
* Tests \Drupal\menu_link_content\Plugin\migrate\process\d7\InternalUri.
*
* @group menu_link_content
*
* @coversDefaultClass \Drupal\menu_link_content\Plugin\migrate\process\d7\InternalUri
*/
class
InternalUriTest
extends
UnitTestCase
{
/**
* The 'd7_internal_uri' process plugin being tested.
*
* @var \Drupal\menu_link_content\Plugin\migrate\process\d7\InternalUri
*/
protected
$processPlugin
;
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
processPlugin
=
new
InternalUri
([],
'd7_internal_uri'
,
[]);
}
/**
* Tests InternalUri::transform().
*
* @param array $value
* The value to pass to InternalUri::transform().
* @param string $expected
* The expected return value of InternalUri::transform().
*
* @dataProvider providerTestTransform
*
* @covers ::transform
*/
public
function
testTransform
(
array
$value
,
$expected
)
{
$migrate_executable
=
$this
->
prophesize
(
MigrateExecutableInterface
::
class
);
$row
=
$this
->
prophesize
(
Row
::
class
);
$actual
=
$this
->
processPlugin
->
transform
(
$value
,
$migrate_executable
->
reveal
(),
$row
->
reveal
(),
'link/uri'
);
$this
->
assertEquals
(
$expected
,
$actual
);
}
/**
* Provides test cases for InternalUriTest::testTransform().
*
* @return array
* An array of test cases, each which the following values:
* - The value array to pass to InternalUri::transform().
* - The expected path returned by InternalUri::transform().
*/
public
function
providerTestTransform
()
{
$tests
=
[];
$tests
[
'with_scheme'
]
=
[[
'http://example.com'
],
'http://example.com'
];
$tests
[
'leading_slash'
]
=
[[
'/test'
],
'internal:/test'
];
$tests
[
'without_scheme'
]
=
[[
'test'
],
'internal:/test'
];
$tests
[
'front'
]
=
[[
'<front>'
],
'internal:/'
];
$tests
[
'node'
]
=
[[
'node/27'
],
'entity:node/27'
];
return
$tests
;
}
}
core/modules/migrate_drupal/tests/fixtures/drupal7.php
View file @
8d783b7c
...
...
@@ -19199,6 +19199,33 @@
'p9' => '0',
'updated' => '0',
))
->values(array(
'menu_name' => 'menu-test-menu',
'mlid' => '470',
'plid' => '469',
'link_path' => 'http://ask.com',
'router_path' => '',
'link_title' => 'Ask',
'options' => 'a:0:{}',
'module' => 'menu',
'hidden' => '0',
'external' => '1',
'has_children' => '0',
'expanded' => '0',
'weight' => '0',
'depth' => '2',
'customized' => '1',
'p1' => '469',
'p2' => '470',
'p3' => '0',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
))
->values(array(
'menu_name' => 'shortcut-set-2',
'mlid' => '472',
...
...
@@ -19334,6 +19361,33 @@
'p9' => '0',
'updated' => '0',
))
->values(array(
'menu_name' => 'navigation',
'mlid' => '479',
'plid' => '0',
'link_path' => 'node/3',
'router_path' => 'node/3',
'link_title' => 'node link test',
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:6:"node 3";}}',
'module' => 'menu',
'hidden' => '0',
'external' => '0',
'has_children' => '0',
'expanded' => '0',
'weight' => '3',
'depth' => '1',
'customized' => '1',
'p1' => '479',
'p2' => '0',
'p3' => '0',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
))
->execute();
$connection->schema()->createTable('menu_router', array(
core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php
View file @
8d783b7c
...
...
@@ -290,7 +290,7 @@ class MigrateUpgradeForm extends ConfirmFormBase {
'source_module'
=>
'locale'
,
'destination_module'
=>
'locale'
,
],
'menu_links'
=>
[
'
d6_
menu_links'
=>
[
'source_module'
=>
'menu'
,
'destination_module'
=>
'menu_link_content'
,
],
...
...
@@ -298,6 +298,10 @@ class MigrateUpgradeForm extends ConfirmFormBase {
'source_module'
=>
'menu'
,
'destination_module'
=>
'menu_ui'
,
],
'd7_menu_links'
=>
[
'source_module'
=>
'menu'
,
'destination_module'
=>
'menu_link_content'
,
],
'd6_node'
=>
[
'source_module'
=>
'node'
,
'destination_module'
=>
'node'
,
...
...
@@ -474,7 +478,11 @@ class MigrateUpgradeForm extends ConfirmFormBase {
'source_module'
=>
'system'
,
'destination_module'
=>
'system'
,
],
'menu'
=>
[
'd6_menu'
=>
[
'source_module'
=>
'menu'
,
'destination_module'
=>
'system'
,
],
'd7_menu'
=>
[
'source_module'
=>
'menu'
,
'destination_module'
=>
'system'
,
],
...
...
core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php
View file @
8d783b7c
...
...
@@ -57,13 +57,13 @@ protected function getEntityCounts() {
'shortcut'
=>
6
,
'shortcut_set'
=>
2
,
'action'
=>
16
,
'menu'
=>
10
,
'menu'
=>
6
,
'taxonomy_term'
=>
18
,
'taxonomy_vocabulary'
=>
3
,
'tour'
=>
4
,
'user'
=>
4
,
'user_role'
=>
3
,
'menu_link_content'
=>
9
,
'menu_link_content'
=>
7
,
'view'
=>
12
,
'date_format'
=>
11
,
'entity_form_display'
=>
16
,
...
...
core/modules/shortcut/migration_templates/d7_shortcut.yml
View file @
8d783b7c
...
...
@@ -23,4 +23,4 @@ destination:
migration_dependencies
:
required
:
-
d7_shortcut_set
-
menu_links
-
d7_
menu_links
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
View file @
8d783b7c
...
...
@@ -34,8 +34,8 @@ protected function setUp() {
$this
->
installEntitySchema
(
'menu_link_content'
);
\
Drupal
::
service
(
'router.builder'
)
->
rebuild
();
$this
->
executeMigration
(
'd7_shortcut_set'
);
$this
->
executeMigration
(
'menu'
);
$this
->
executeMigration
(
'menu_links'
);
$this
->
executeMigration
(
'
d7_
menu'
);
$this
->
executeMigration
(
'
d7_
menu_links'
);
$this
->
executeMigration
(
'd7_shortcut'
);
}
...
...
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetUsersTest.php
View file @
8d783b7c
...
...
@@ -36,8 +36,8 @@ protected function setUp() {
$this
->
executeMigration
(
'd7_user_role'
);
$this
->
executeMigration
(
'd7_user'
);
$this
->
executeMigration
(
'd7_shortcut_set'
);
$this
->
executeMigration
(
'menu'
);
$this
->
executeMigration
(
'menu_links'
);
$this
->
executeMigration
(
'
d7_
menu'
);
$this
->
executeMigration
(
'
d7_
menu_links'
);
$this
->
executeMigration
(
'd7_shortcut'
);
$this
->
executeMigration
(
'd7_shortcut_set_users'
);
}
...
...
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
View file @
8d783b7c
...
...
@@ -34,8 +34,8 @@ protected function setUp() {
$this
->
installEntitySchema
(
'menu_link_content'
);
\
Drupal
::
service
(
'router.builder'
)
->
rebuild
();
$this
->
executeMigration
(
'd7_shortcut_set'
);
$this
->
executeMigration
(
'menu'
);
$this
->
executeMigration
(
'menu_links'
);
$this
->
executeMigration
(
'
d7_
menu'
);
$this
->
executeMigration
(
'
d7_
menu_links'
);
$this
->
executeMigration
(
'd7_shortcut'
);
}
...
...
core/modules/system/migration_templates/menu.yml
→
core/modules/system/migration_templates/
d6_
menu.yml
View file @
8d783b7c
# The menu_settings migration is in the menu_ui module.
id
:
menu
id
:
d6_
menu
label
:
Menus
migration_tags
:
-
Drupal
6
-
Drupal
7
source
:
plugin
:
menu
process
:
...
...
core/modules/system/migration_templates/d7_menu.yml
0 → 100644
View file @
8d783b7c
id
:
d7_menu
label
:
Menus
migration_tags
:
-
Drupal
7
source
:
plugin
:
menu
process
:
id
:
plugin
:
static_map
bypass
:
true
source
:
menu_name
map
:
main-menu
:
main
management
:
admin
navigation
:
tools
user-menu
:
account
label
:
title
description
:
description
destination
:
plugin
:
entity:menu
core/modules/system/tests/src/Kernel/Migrate/MigrateMenuTest.php
→
core/modules/system/tests/src/Kernel/Migrate/
d6/
MigrateMenuTest.php
View file @
8d783b7c
<?php
namespace
Drupal\Tests\system\Kernel\Migrate
;
namespace
Drupal\Tests\system\Kernel\Migrate
\d6
;
use
Drupal\Core\Database\Database
;
use
Drupal\Tests\migrate_drupal
\
Kernel\d6\MigrateDrupal6TestBase
;
...
...
@@ -18,7 +18,7 @@ class MigrateMenuTest extends MigrateDrupal6TestBase {
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
executeMigration
(
'menu'
);
$this
->
executeMigration
(
'
d6_
menu'
);
}
/**
...
...
@@ -26,12 +26,12 @@ protected function setUp() {
*/
public
function
testMenu
()
{
$navigation_menu
=
Menu
::
load
(
'navigation'
);
$this
->
assert
Identical
(
'navigation'
,
$navigation_menu
->
id
());
$this
->
assert
Identical
(
'Navigation'
,
$navigation_menu
->
label
());
$this
->
assert
Same
(
'navigation'
,
$navigation_menu
->
id
());
$this
->
assert
Same
(
'Navigation'
,
$navigation_menu
->
label
());
$expected
=
<<<EOT
The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.
EOT;
$this
->
assert
Identical
(
$expected
,
$navigation_menu
->
getDescription
());
$this
->
assert
Same
(
$expected
,
$navigation_menu
->
getDescription
());
// Test that we can re-import using the ConfigEntityBase destination.
Database
::
getConnection
(
'default'
,
'migrate'
)
...
...
@@ -40,14 +40,14 @@ public function testMenu() {
->
condition
(
'menu_name'
,
'navigation'
)
->
execute
();
$migration
=
$this
->
getMigration
(
'menu'
);
$migration
=
$this
->
getMigration
(
'
d6_
menu'
);
\
Drupal
::
database
()
->
truncate
(
$migration
->
getIdMap
()
->
mapTableName
())
->
execute
();
$this
->
executeMigration
(
$migration
);
$navigation_menu
=
Menu
::
load
(
'navigation'
);
$this
->
assert
Identical
(
'Home Navigation'
,
$navigation_menu
->
label
());
$this
->
assert
Same
(
'Home Navigation'
,
$navigation_menu
->
label
());
}
}
core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
0 → 100644
View file @
8d783b7c
<?php
namespace
Drupal\Tests\system\Kernel\Migrate\d7
;
use
Drupal\Core\Database\Database
;
use
Drupal\Tests\migrate_drupal
\
Kernel\d7\MigrateDrupal7TestBase
;
use
Drupal\system\Entity\Menu
;
/**
* Upgrade menus to system.menu.*.yml.
*
* @group migrate_drupal_7
*/
class
MigrateMenuTest
extends
MigrateDrupal7TestBase
{
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
executeMigration
(
'd7_menu'
);
}
/**
* Asserts various aspects of a menu.
*
* @param $id
* The menu ID.
* @param $label
* The menu label.
* @param $description
* The menu description.
*/
protected
function
assertEntity
(
$id
,
$label
,
$description
)
{
$navigation_menu
=
Menu
::
load
(
$id
);
$this
->
assertSame
(
$id
,
$navigation_menu
->
id
());
$this
->
assertSame
(
$label
,
$navigation_menu
->
label
());
$this
->
assertSame
(
$description
,
$navigation_menu
->
getDescription
());
}
/**
* Tests the Drupal 7 menu to Drupal 8 migration.
*/