Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -0,0 +1,7 @@
|
|||
migrate.source.d6_menu_link:
|
||||
type: migrate_source_sql
|
||||
label: 'Drupal 6 menu link'
|
||||
mapping:
|
||||
constants:
|
||||
type: migrate_entity_constant
|
||||
label: 'Constants'
|
|
@ -0,0 +1,47 @@
|
|||
id: d6_menu_links
|
||||
label: Drupal 6 menu links
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_menu_link
|
||||
constants:
|
||||
bundle: menu_link_content
|
||||
process:
|
||||
id: mlid
|
||||
bundle: 'constants/bundle'
|
||||
title: link_title
|
||||
description:
|
||||
plugin: extract
|
||||
source:
|
||||
- options
|
||||
index:
|
||||
- 0
|
||||
- attributes
|
||||
- title
|
||||
menu_name:
|
||||
plugin: migration
|
||||
migration: d6_menu
|
||||
source: menu_name
|
||||
'link/uri':
|
||||
plugin: internal_uri
|
||||
source:
|
||||
- link_path
|
||||
'link/options': options
|
||||
external: external
|
||||
weight: weight
|
||||
expanded: expanded
|
||||
enabled: enabled
|
||||
parent:
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
source: plid
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_menu_links
|
||||
changed: updated
|
||||
destination:
|
||||
plugin: entity:menu_link_content
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_menu
|
|
@ -19,7 +19,10 @@ class MenuLinkContentDeleteForm extends ContentEntityDeleteForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCancelUrl() {
|
||||
return new Url('entity.menu.edit_form', array('menu' => $this->entity->getMenuName()));
|
||||
if ($this->moduleHandler->moduleExists('menu_ui')) {
|
||||
return new Url('entity.menu.edit_form', array('menu' => $this->entity->getMenuName()));
|
||||
}
|
||||
return $this->entity->urlInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\menu_link_content\Plugin\Menu;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginException;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Menu\MenuLinkBase;
|
||||
|
@ -138,7 +137,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
|||
$entity = reset($loaded_entities);
|
||||
}
|
||||
if (!$entity) {
|
||||
throw new PluginException(SafeMarkup::format('Entity not found through the menu link plugin definition and could not fallback on UUID @uuid', array('@uuid' => $uuid)));
|
||||
throw new PluginException("Entity not found through the menu link plugin definition and could not fallback on UUID '$uuid'");
|
||||
}
|
||||
// Clone the entity object to avoid tampering with the static cache.
|
||||
$this->entity = clone $entity;
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLink.
|
||||
*/
|
||||
|
||||
namespace Drupal\menu_link_content\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 menu link source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_menu_link",
|
||||
* )
|
||||
*/
|
||||
class MenuLink extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('menu_links', 'ml')
|
||||
->fields('ml', array(
|
||||
'menu_name',
|
||||
'mlid',
|
||||
'plid',
|
||||
'link_path',
|
||||
'router_path',
|
||||
'link_title',
|
||||
'options',
|
||||
'module',
|
||||
'hidden',
|
||||
'external',
|
||||
'has_children',
|
||||
'expanded',
|
||||
'weight',
|
||||
'depth',
|
||||
'customized',
|
||||
'p1',
|
||||
'p2',
|
||||
'p3',
|
||||
'p4',
|
||||
'p5',
|
||||
'p6',
|
||||
'p7',
|
||||
'p8',
|
||||
'p9',
|
||||
'updated'
|
||||
))
|
||||
->condition('module', 'menu')
|
||||
->condition('customized', 1);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'menu_name' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
|
||||
'mlid' => t('The menu link ID (mlid) is the integer primary key.'),
|
||||
'plid' => t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
|
||||
'link_path' => t('The Drupal path or external path this link points to.'),
|
||||
'router_path' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'),
|
||||
'link_title' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'),
|
||||
'options' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'),
|
||||
'module' => t('The name of the module that generated this link.'),
|
||||
'hidden' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
|
||||
'external' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'),
|
||||
'has_children' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'),
|
||||
'expanded' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)'),
|
||||
'weight' => t('Link weight among links in the same menu at the same depth.'),
|
||||
'depth' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'),
|
||||
'customized' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'),
|
||||
'p1' => t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
|
||||
'p2' => t('The second mlid in the materialized path. See p1.'),
|
||||
'p3' => t('The third mlid in the materialized path. See p1.'),
|
||||
'p4' => t('The fourth mlid in the materialized path. See p1.'),
|
||||
'p5' => t('The fifth mlid in the materialized path. See p1.'),
|
||||
'p6' => t('The sixth mlid in the materialized path. See p1.'),
|
||||
'p7' => t('The seventh mlid in the materialized path. See p1.'),
|
||||
'p8' => t('The eighth mlid in the materialized path. See p1.'),
|
||||
'p9' => t('The ninth mlid in the materialized path. See p1.'),
|
||||
'updated' => t('Flag that indicates that this link was generated during the update from Drupal 5.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
|
||||
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['mlid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,9 +8,9 @@
|
|||
namespace Drupal\menu_link_content\Tests;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Menu\MenuTreeParameters;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\user\Entity\User;
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Ensures that rendered menu links bubble the necessary cacheability metadata
|
||||
* Ensures that rendered menu links bubble the necessary bubbleable metadata
|
||||
* for outbound path/route processing.
|
||||
*
|
||||
* @group menu_link_content
|
||||
|
@ -47,7 +47,7 @@ class MenuLinkContentCacheabilityBubblingTest extends KernelTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests bubbling of menu links' outbound route/path processing cacheability.
|
||||
* Tests bubbleable metadata of menu links' outbound route/path processing.
|
||||
*/
|
||||
public function testOutboundPathAndRouteProcessing() {
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
@ -66,10 +66,10 @@ class MenuLinkContentCacheabilityBubblingTest extends KernelTestBase {
|
|||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
|
||||
$default_menu_cacheability = (new CacheableMetadata())
|
||||
$default_menu_cacheability = (new BubbleableMetadata())
|
||||
->setCacheMaxAge(Cache::PERMANENT)
|
||||
->setCacheTags(['config:system.menu.tools'])
|
||||
->setCacheContexts(['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme']);
|
||||
->setCacheContexts(['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions']);
|
||||
|
||||
User::create(['uid' => 1, 'name' => $this->randomString()])->save();
|
||||
User::create(['uid' => 2, 'name' => $this->randomString()])->save();
|
||||
|
@ -87,26 +87,26 @@ class MenuLinkContentCacheabilityBubblingTest extends KernelTestBase {
|
|||
// \Drupal\Core\RouteProcessor\RouteProcessorCurrent: 'route' cache context.
|
||||
[
|
||||
'uri' => 'route:<current>',
|
||||
'cacheability' => (new CacheableMetadata())->setCacheContexts(['route']),
|
||||
'cacheability' => (new BubbleableMetadata())->setCacheContexts(['route']),
|
||||
],
|
||||
// \Drupal\Core\Access\RouteProcessorCsrf: max-age = 0.
|
||||
// \Drupal\Core\Access\RouteProcessorCsrf: placeholder.
|
||||
[
|
||||
'uri' => 'route:outbound_processing_test.route.csrf',
|
||||
'cacheability' => (new CacheableMetadata())->setCacheMaxAge(0),
|
||||
'cacheability' => (new BubbleableMetadata())->setCacheContexts(['session'])->setAttachments(['placeholders' => []]),
|
||||
],
|
||||
// \Drupal\Core\PathProcessor\PathProcessorFront: permanently cacheable.
|
||||
[
|
||||
'uri' => 'internal:/',
|
||||
'cacheability' => (new CacheableMetadata()),
|
||||
'cacheability' => (new BubbleableMetadata()),
|
||||
],
|
||||
// \Drupal\url_alter_test\PathProcessorTest: user entity's cache tags.
|
||||
[
|
||||
'uri' => 'internal:/user/1',
|
||||
'cacheability' => (new CacheableMetadata())->setCacheTags(User::load(1)->getCacheTags()),
|
||||
'cacheability' => (new BubbleableMetadata())->setCacheTags(User::load(1)->getCacheTags()),
|
||||
],
|
||||
[
|
||||
'uri' => 'internal:/user/2',
|
||||
'cacheability' => (new CacheableMetadata())->setCacheTags(User::load(2)->getCacheTags()),
|
||||
'cacheability' => (new BubbleableMetadata())->setCacheTags(User::load(2)->getCacheTags()),
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -122,7 +122,7 @@ class MenuLinkContentCacheabilityBubblingTest extends KernelTestBase {
|
|||
$renderer->renderRoot($build);
|
||||
|
||||
$expected_cacheability = $default_menu_cacheability->merge($expectation['cacheability']);
|
||||
$this->assertEqual($expected_cacheability, CacheableMetadata::createFromRenderArray($build));
|
||||
$this->assertEqual($expected_cacheability, BubbleableMetadata::createFromRenderArray($build));
|
||||
|
||||
$menu_link_content->delete();
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class MenuLinkContentCacheabilityBubblingTest extends KernelTestBase {
|
|||
// Now test them all together in one menu: the rendered menu's cacheability
|
||||
// metadata should be the combination of the cacheability of all links, and
|
||||
// thus of all tested outbound path & route processors.
|
||||
$expected_cacheability = new CacheableMetadata();
|
||||
$expected_cacheability = new BubbleableMetadata();
|
||||
foreach ($test_cases as $expectation) {
|
||||
$menu_link_content = MenuLinkContent::create([
|
||||
'link' => ['uri' => $expectation['uri']],
|
||||
|
@ -143,7 +143,7 @@ class MenuLinkContentCacheabilityBubblingTest extends KernelTestBase {
|
|||
$build = $menu_tree->build($tree);
|
||||
$renderer->renderRoot($build);
|
||||
$expected_cacheability = $expected_cacheability->merge($default_menu_cacheability);
|
||||
$this->assertEqual($expected_cacheability, CacheableMetadata::createFromRenderArray($build));
|
||||
$this->assertEqual($expected_cacheability, BubbleableMetadata::createFromRenderArray($build));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\menu_link_content\Tests\MenuLinkContentDeleteFormTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\menu_link_content\Tests;
|
||||
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\system\Entity\Menu;
|
||||
|
||||
/**
|
||||
* Tests the menu link content delete UI.
|
||||
*
|
||||
* @group Menu
|
||||
*/
|
||||
class MenuLinkContentDeleteFormTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['menu_link_content'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$web_user = $this->drupalCreateUser(['administer menu']);
|
||||
$this->drupalLogin($web_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the MenuLinkContentDeleteForm class.
|
||||
*/
|
||||
public function testMenuLinkContentDeleteForm() {
|
||||
// Add new menu item.
|
||||
$this->drupalPostForm(
|
||||
'admin/structure/menu/manage/admin/add',
|
||||
[
|
||||
'title[0][value]' => t('Front page'),
|
||||
'link[0][uri]' => '<front>',
|
||||
],
|
||||
t('Save')
|
||||
);
|
||||
$this->assertText(t('The menu link has been saved.'));
|
||||
|
||||
$menu_link = MenuLinkContent::load(1);
|
||||
$this->drupalGet($menu_link->urlInfo('delete-form'));
|
||||
$this->assertRaw(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()]));
|
||||
$this->assertLink(t('Cancel'));
|
||||
// Make sure cancel link points to link edit
|
||||
$this->assertLinkByHref($menu_link->url('edit-form'));
|
||||
|
||||
\Drupal::service('module_installer')->install(['menu_ui']);
|
||||
// Make sure cancel URL points to menu_ui route now.
|
||||
$this->drupalGet($menu_link->urlInfo('delete-form'));
|
||||
$menu = Menu::load($menu_link->getMenuName());
|
||||
$this->assertLinkByHref($menu->url('edit-form'));
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
$this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()]));
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
namespace Drupal\menu_link_content\Tests;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Menu\MenuTreeParameters;
|
||||
use Drupal\Core\StringTranslation\TranslationWrapper;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
@ -45,7 +47,7 @@ class MenuLinkContentDeriverTest extends KernelTestBase {
|
|||
|
||||
// Set up a custom menu link pointing to a specific path.
|
||||
MenuLinkContent::create([
|
||||
'title' => 'Example',
|
||||
'title' => '<script>alert("Welcome to the discovered jungle!")</script>',
|
||||
'link' => [['uri' => 'internal:/example-path']],
|
||||
'menu_name' => 'tools',
|
||||
])->save();
|
||||
|
@ -67,6 +69,10 @@ class MenuLinkContentDeriverTest extends KernelTestBase {
|
|||
/** @var \Drupal\Core\Menu\MenuLinkTreeElement $tree_element */
|
||||
$tree_element = reset($menu_tree);
|
||||
$this->assertEqual('route_name_2', $tree_element->link->getRouteName());
|
||||
$title = $tree_element->link->getTitle();
|
||||
$this->assertFalse($title instanceof TranslationWrapper);
|
||||
$this->assertIdentical('<script>alert("Welcome to the discovered jungle!")</script>', $title);
|
||||
$this->assertFalse(SafeMarkup::isSafe($title));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ class MenuLinkContentFormTest extends WebTestBase {
|
|||
*/
|
||||
public static $modules = array(
|
||||
'menu_link_content',
|
||||
'menu_ui',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,11 @@ use Drupal\menu_link_content\Entity\MenuLinkContent;
|
|||
*/
|
||||
class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
|
||||
|
||||
/**
|
||||
* {inheritdoc}
|
||||
*/
|
||||
protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'user.permissions', 'user.roles:authenticated'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\menu_link_content\Tests\Migrate\d6\MigrateMenuLinkTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\menu_link_content\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Menu link migration.
|
||||
*
|
||||
* @group menu_link_content
|
||||
*/
|
||||
class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('link', 'menu_ui', 'menu_link_content');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', ['router']);
|
||||
$this->installEntitySchema('menu_link_content');
|
||||
|
||||
$menu = entity_create('menu', array('id' => 'secondary-links'));
|
||||
$menu->enforceIsNew(TRUE);
|
||||
$menu->save();
|
||||
|
||||
$this->prepareMigrations(array(
|
||||
'd6_menu' => array(
|
||||
array(array('secondary-links'), array('secondary-links')),
|
||||
),
|
||||
));
|
||||
|
||||
$this->loadDumps(['MenuLinks.php']);
|
||||
$this->executeMigration('d6_menu_links');
|
||||
}
|
||||
|
||||
public function testMenuLinks() {
|
||||
$menu_link = entity_load('menu_link_content', 138);
|
||||
$this->assertIdentical('Test 1', $menu_link->getTitle());
|
||||
$this->assertIdentical('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertIdentical('Test menu link 1', $menu_link->getDescription());
|
||||
$this->assertIdentical(TRUE, $menu_link->isEnabled());
|
||||
$this->assertIdentical(FALSE, $menu_link->isExpanded());
|
||||
$this->assertIdentical(['attributes' => ['title' => 'Test menu link 1']], $menu_link->link->options);
|
||||
$this->assertIdentical('internal:/user/login', $menu_link->link->uri);
|
||||
$this->assertIdentical(15, $menu_link->getWeight());
|
||||
|
||||
$menu_link = entity_load('menu_link_content', 139);
|
||||
$this->assertIdentical('Test 2', $menu_link->getTitle());
|
||||
$this->assertIdentical('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertIdentical('Test menu link 2', $menu_link->getDescription());
|
||||
$this->assertIdentical(TRUE, $menu_link->isEnabled());
|
||||
$this->assertIdentical(TRUE, $menu_link->isExpanded());
|
||||
$this->assertIdentical(['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
|
||||
$this->assertIdentical('internal:/admin', $menu_link->link->uri);
|
||||
$this->assertIdentical(12, $menu_link->getWeight());
|
||||
|
||||
$menu_link = entity_load('menu_link_content', 140);
|
||||
$this->assertIdentical('Drupal.org', $menu_link->getTitle());
|
||||
$this->assertIdentical('secondary-links', $menu_link->getMenuName());
|
||||
$this->assertIdentical('', $menu_link->getDescription());
|
||||
$this->assertIdentical(TRUE, $menu_link->isEnabled());
|
||||
$this->assertIdentical(FALSE, $menu_link->isExpanded());
|
||||
$this->assertIdentical(['attributes' => ['title' => '']], $menu_link->link->options);
|
||||
$this->assertIdentical('https://www.drupal.org', $menu_link->link->uri);
|
||||
$this->assertIdentical(0, $menu_link->getWeight());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\menu_link_content\Unit\Plugin\migrate\source\d6\MenuLinkSourceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\menu_link_content\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 menu link source plugin.
|
||||
*
|
||||
* @group menu_link_content
|
||||
*/
|
||||
class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLink';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'mlid',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'drupal6_menu_link',
|
||||
),
|
||||
'sourceIds' => array(
|
||||
'mlid' => array(
|
||||
// This is where the field schema would go but for now we need to
|
||||
// specify the table alias for the key. Most likely this will be the
|
||||
// same as BASE_ALIAS.
|
||||
'alias' => 'ml',
|
||||
),
|
||||
),
|
||||
'destinationIds' => array(
|
||||
'mlid' => array(
|
||||
// This is where the field schema would go.
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 138,
|
||||
'plid' => 0,
|
||||
'link_path' => 'admin',
|
||||
'router_path' => 'admin',
|
||||
'link_title' => 'Test 1',
|
||||
'options' => array('attributes' => array('title' => 'Test menu link 1')),
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 1,
|
||||
'expanded' => 0,
|
||||
'weight' => 15,
|
||||
'depth' => 1,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
),
|
||||
array(
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 139,
|
||||
'plid' => 138,
|
||||
'link_path' => 'admin/modules',
|
||||
'router_path' => 'admin/modules',
|
||||
'link_title' => 'Test 2',
|
||||
'options' => array('attributes' => array('title' => 'Test menu link 2')),
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 0,
|
||||
'expanded' => 0,
|
||||
'weight' => 12,
|
||||
'depth' => 2,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '139',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
// This array stores the database.
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['menu_links'][$k] = $row;
|
||||
$this->databaseContents['menu_links'][$k]['options'] = serialize($this->databaseContents['menu_links'][$k]['options']);
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue