Issue #2333985 by quietone, jarsenx, ultimike, heddn: Migrate menu_default_node_menu setting

8.4.x
Nathaniel Catchpole 2017-04-18 13:58:04 +01:00
parent 8938ab2906
commit 5875eb523c
51 changed files with 149 additions and 34 deletions

View File

@ -15,7 +15,7 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['book'];
public static $modules = ['book', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -17,7 +17,7 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['comment'];
public static $modules = ['comment', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -11,6 +11,11 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay;
*/
class MigrateCommentVariableEntityDisplayTest extends MigrateCommentVariableDisplayBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -11,6 +11,11 @@ use Drupal\Core\Entity\Entity\EntityFormDisplay;
*/
class MigrateCommentVariableEntityFormDisplayTest extends MigrateCommentVariableDisplayBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -15,7 +15,7 @@ class MigrateCommentVariableFieldTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['comment'];
public static $modules = ['comment', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -16,7 +16,7 @@ class MigrateCommentVariableInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['comment'];
public static $modules = ['comment', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'comment', 'text'];
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'comment', 'text'];
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'comment', 'text'];
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -15,7 +15,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCommentFieldInstanceTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'comment', 'text'];
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -14,7 +14,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCommentFieldTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'comment', 'text'];
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -14,7 +14,7 @@ use Drupal\node\NodeInterface;
*/
class MigrateCommentTest extends MigrateDrupal7TestBase {
public static $modules = ['filter', 'node', 'comment', 'text'];
public static $modules = ['filter', 'node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -13,7 +13,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'comment', 'text'];
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -12,6 +12,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -14,6 +14,11 @@ use Drupal\node\Entity\Node;
*/
class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* Tests migration of file variables to file.settings.yml.
*/

View File

@ -12,6 +12,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -29,6 +29,7 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
'taxonomy',
'telephone',
'text',
'menu_ui',
];
/**

View File

@ -12,6 +12,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -12,6 +12,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -12,6 +12,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateUploadFieldTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -12,6 +12,11 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateUploadInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -13,6 +13,11 @@ use Drupal\node\Entity\Node;
*/
class MigrateUploadTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -16,7 +16,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'text', 'language', 'content_translation'];
public static $modules = ['node', 'text', 'language', 'content_translation', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -16,7 +16,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'text', 'language', 'content_translation'];
public static $modules = ['node', 'text', 'language', 'content_translation', 'menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -46081,6 +46081,10 @@ $connection->insert('variable')
'name',
'value',
))
->values(array(
'name' => 'menu_default_node_menu',
'value' => 's:10:"navigation";',
))
->values(array(
'name' => 'actions_max_stack',
'value' => 'i:35;',

View File

@ -20,5 +20,7 @@ process:
'settings/node/options': options
create_body: has_body
create_body_label: body_label
'third_party_settings/menu_ui/available_menus': available_menus
'third_party_settings/menu_ui/parent': parent
destination:
plugin: entity:node_type

View File

@ -17,5 +17,7 @@ process:
new_revision: 'options/revision'
create_body: create_body
create_body_label: body_label
'third_party_settings/menu_ui/available_menus': available_menus
'third_party_settings/menu_ui/parent': parent
destination:
plugin: entity:node_type

View File

@ -107,6 +107,10 @@ class NodeType extends DrupalSqlBase {
$submitted = isset($this->themeSettings['toggle_node_info_' . $type]) ? $this->themeSettings['toggle_node_info_' . $type] : FALSE;
$row->setSourceProperty('display_submitted', $submitted);
if ($default_node_menu = $this->variableGet('menu_default_node_menu', NULL)) {
$row->setSourceProperty('available_menus', [$default_node_menu]);
$row->setSourceProperty('parent', $default_node_menu . ':');
}
return parent::prepareRow($row);
}

View File

@ -101,6 +101,12 @@ class NodeType extends DrupalSqlBase {
$row->setSourceProperty('display_submitted', $this->variableGet('node_submitted_' . $type, TRUE));
if ($menu_options = $this->variableGet('menu_options_' . $type, NULL)) {
$row->setSourceProperty('available_menus', $menu_options);
}
if ($parent = $this->variableGet('menu_parent_' . $type, NULL)) {
$row->setSourceProperty('parent', $parent . ':');
}
return parent::prepareRow($row);
}

View File

@ -13,7 +13,7 @@ class MigrateNodeRevisionTest extends MigrateNodeTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['language', 'content_translation'];
public static $modules = ['language', 'content_translation', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -13,6 +13,11 @@ use Drupal\node\Entity\Node;
*/
class MigrateNodeBundleSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/

View File

@ -10,7 +10,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateNodeSettingPromoteTest extends MigrateDrupal6TestBase {
public static $modules = ['node', 'text'];
public static $modules = ['node', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -10,7 +10,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateNodeSettingStatusTest extends MigrateDrupal6TestBase {
public static $modules = ['node', 'text'];
public static $modules = ['node', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -10,7 +10,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateNodeSettingStickyTest extends MigrateDrupal6TestBase {
public static $modules = ['node', 'text'];
public static $modules = ['node', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -19,7 +19,7 @@ class MigrateNodeTest extends MigrateNodeTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['language', 'content_translation'];
public static $modules = ['language', 'content_translation', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -13,6 +13,11 @@ use Drupal\node\Entity\NodeType;
*/
class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
/**
* {@inheritdoc}
*/
@ -39,6 +44,12 @@ class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
$field = FieldConfig::loadByName('node', 'test_page', 'body');
$this->assertIdentical('This is the body field label', $field->getLabel(), 'Body field was found.');
// Test default menus.
$expected_available_menus = ['navigation'];
$this->assertSame($expected_available_menus, $node_type_page->getThirdPartySetting('menu_ui', 'available_menus'));
$expected_parent = 'navigation:';
$this->assertSame($expected_parent, $node_type_page->getThirdPartySetting('menu_ui', 'parent'));
// Test the test_story content type.
$node_type_story = NodeType::load('test_story');
$this->assertIdentical('test_story', $node_type_story->id(), 'Node type test_story loaded');
@ -52,6 +63,12 @@ class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
$field = FieldConfig::loadByName('node', 'test_story', 'body');
$this->assertIdentical(NULL, $field, 'No body field found');
// Test default menus.
$expected_available_menus = ['navigation'];
$this->assertSame($expected_available_menus, $node_type_story->getThirdPartySetting('menu_ui', 'available_menus'));
$expected_parent = 'navigation:';
$this->assertSame($expected_parent, $node_type_story->getThirdPartySetting('menu_ui', 'parent'));
// Test the test_event content type.
$node_type_event = NodeType::load('test_event');
$this->assertIdentical('test_event', $node_type_event->id(), 'Node type test_event loaded');
@ -64,6 +81,11 @@ class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_event', 'body');
$this->assertIdentical('Body', $field->getLabel(), 'Body field was found.');
$expected_available_menus = ['navigation'];
$this->assertSame($expected_available_menus, $node_type_event->getThirdPartySetting('menu_ui', 'available_menus'));
$expected_parent = 'navigation:';
$this->assertSame($expected_parent, $node_type_event->getThirdPartySetting('menu_ui', 'parent'));
}
}

View File

@ -24,6 +24,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
'image',
'language',
'link',
'menu_ui',
'node',
'taxonomy',
'telephone',

View File

@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateNodeTitleLabelTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'text'];
public static $modules = ['node', 'text', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -20,7 +20,7 @@ class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
*
* @var array
*/
public static $modules = ['node', 'text', 'filter'];
public static $modules = ['node', 'text', 'filter', 'menu_ui'];
/**
* {@inheritdoc}
@ -45,12 +45,13 @@ class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
* @param string $help
* The expected help text.
*/
protected function assertEntity($id, $label, $description, $help, $display_submitted, $new_revision, $body_label = NULL) {
protected function assertEntity($id, $label, $description, $help, $display_submitted, $new_revision, $expected_available_menus, $expected_parent, $body_label = NULL) {
/** @var \Drupal\node\NodeTypeInterface $entity */
$entity = NodeType::load($id);
$this->assertTrue($entity instanceof NodeTypeInterface);
$this->assertIdentical($label, $entity->label());
$this->assertIdentical($description, $entity->getDescription());
$this->assertIdentical($help, $entity->getHelp());
$this->assertIdentical($display_submitted, $entity->displaySubmitted(), 'Submission info is displayed');
@ -62,20 +63,32 @@ class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
$this->assertTrue($body instanceof FieldConfigInterface);
$this->assertIdentical($body_label, $body->label());
}
$this->assertSame($expected_available_menus, $entity->getThirdPartySetting('menu_ui', 'available_menus'));
$this->assertSame($expected_parent, $entity->getThirdPartySetting('menu_ui', 'parent'));
}
/**
* Tests Drupal 7 node type to Drupal 8 migration.
*/
public function testNodeType() {
$this->assertEntity('article', 'Article', 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.', 'Help text for articles', TRUE, FALSE, "Body");
$this->assertEntity('blog', 'Blog entry', 'Use for multi-user blogs. Every user gets a personal blog.', 'Blog away, good sir!', TRUE, FALSE, 'Body');
$expected_available_menus = ['main-menu'];
$expected_parent = 'main-menu:0:';
$this->assertEntity('article', 'Article', 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.', 'Help text for articles', TRUE, FALSE, $expected_available_menus, $expected_parent, "Body");
$this->assertEntity('blog', 'Blog entry', 'Use for multi-user blogs. Every user gets a personal blog.', 'Blog away, good sir!', TRUE, FALSE, $expected_available_menus, $expected_parent, 'Body');
// book's display_submitted flag is not set, so it will default to TRUE.
$this->assertEntity('book', 'Book page', '<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.', '', TRUE, TRUE, "Body");
$this->assertEntity('forum', 'Forum topic', 'A <em>forum topic</em> starts a new discussion thread within a forum.', 'No name-calling, no flame wars. Be nice.', TRUE, FALSE, 'Body');
$this->assertEntity('page', 'Basic page', "Use <em>basic pages</em> for your static content, such as an 'About us' page.", 'Help text for basic pages', FALSE, FALSE, "Body");
$this->assertEntity('book', 'Book page', '<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.', '', TRUE, TRUE, $expected_available_menus, $expected_parent, "Body");
$this->assertEntity('forum', 'Forum topic', 'A <em>forum topic</em> starts a new discussion thread within a forum.', 'No name-calling, no flame wars. Be nice.', TRUE, FALSE, $expected_available_menus, $expected_parent, 'Body');
$this->assertEntity('page', 'Basic page', "Use <em>basic pages</em> for your static content, such as an 'About us' page.", 'Help text for basic pages', FALSE, FALSE, $expected_available_menus, $expected_parent, "Body");
// This node type does not carry a body field.
$this->assertEntity('test_content_type', 'Test content type', 'This is the description of the test content type.', 'Help text for test content type', FALSE, TRUE);
$expected_available_menus = [
'main-menu',
'management',
'navigation',
'user-menu',
];
$this->assertEntity('test_content_type', 'Test content type', 'This is the description of the test content type.', 'Help text for test content type', FALSE, TRUE, $expected_available_menus, $expected_parent);
}
}

View File

@ -16,7 +16,7 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['language', 'content_translation', 'path'];
public static $modules = ['language', 'content_translation', 'path', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -17,6 +17,7 @@ class MigrateUrlAliasTest extends MigrateDrupal7TestBase {
public static $modules = [
'content_translation',
'language',
'menu_ui',
'node',
'path',
'text',

View File

@ -14,7 +14,7 @@ class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
public static $modules = ['taxonomy', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -15,7 +15,7 @@ class MigrateTermNodeTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
public static $modules = ['taxonomy', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -15,7 +15,7 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['field', 'taxonomy'];
public static $modules = ['field', 'taxonomy', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -15,7 +15,7 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
public static $modules = ['taxonomy', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -15,7 +15,7 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
public static $modules = ['taxonomy', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -15,7 +15,7 @@ class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy'];
public static $modules = ['taxonomy', 'menu_ui'];
/**
* {@inheritdoc}

View File

@ -20,6 +20,7 @@ class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
'filter',
'image',
'link',
'menu_ui',
'node',
'taxonomy',
'telephone',

View File

@ -18,6 +18,7 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase {
'datetime',
'image',
'link',
'menu_ui',
'node',
'taxonomy',
'telephone',

View File

@ -16,6 +16,7 @@ class MigrateTrackerNodeTest extends MigrateDrupal7TestBase {
* {@inheritdoc}
*/
public static $modules = [
'menu_ui',
'node',
'text',
'tracker',

View File

@ -16,6 +16,7 @@ class MigrateTrackerUserTest extends MigrateDrupal7TestBase {
* {@inheritdoc}
*/
public static $modules = [
'menu_ui',
'node',
'text',
'tracker',