summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/menu/menu.install43
-rw-r--r--modules/simpletest/simpletest.info3
-rw-r--r--modules/simpletest/tests/upgrade/drupal-6.menu.database.php10
-rw-r--r--modules/simpletest/tests/upgrade/upgrade.menu.test44
4 files changed, 99 insertions, 1 deletions
diff --git a/modules/menu/menu.install b/modules/menu/menu.install
index 05aed283f..717c5e712 100644
--- a/modules/menu/menu.install
+++ b/modules/menu/menu.install
@@ -69,3 +69,46 @@ function menu_uninstall() {
menu_rebuild();
}
+/**
+ * @defgroup updates-7.x-extra Extra updates for 7.x
+ * @{
+ */
+
+/**
+ * Migrate the "Default menu for content" setting to individual node types.
+ */
+function menu_update_7000() {
+ // Act only on sites originally on Drupal 6 that have a custom "Default menu
+ // for content" setting.
+ $default_node_menu = variable_get('menu_default_node_menu');
+ if (isset($default_node_menu)) {
+ // Remove variable no longer used in Drupal 7.
+ variable_del('menu_default_node_menu');
+
+ // Make sure the menu chosen as the default still exists.
+ $defined_menus = db_query('SELECT * FROM {menu_custom}')->fetchAllAssoc('menu_name', PDO::FETCH_ASSOC);
+ // If the menu does not exist, do nothing; nodes will use the default D7
+ // node menu settings.
+ if (!isset($defined_menus[$default_node_menu])) {
+ return;
+ }
+
+ // Update the menu settings for each node type.
+ foreach (_update_7000_node_get_types() as $type => $type_object) {
+ $type_menus = variable_get('menu_options_' . $type);
+ // If the site already has a custom menu setting for this node type (set
+ // on the initial upgrade to Drupal 7.0), don't override it.
+ if (!isset($type_menus)) {
+ // Set up this node type so that the Drupal 6 "Default menu for content"
+ // is still available in the "Menu settings" section.
+ variable_set('menu_options_' . $type, array($default_node_menu));
+ variable_set('menu_parent_' . $type, $default_node_menu . ':0');
+ }
+ }
+ }
+}
+
+/**
+ * @} End of "defgroup updates-7.x-extra"
+ * The next series of updates should start at 8000.
+ */
diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info
index 26647b7a2..015542208 100644
--- a/modules/simpletest/simpletest.info
+++ b/modules/simpletest/simpletest.info
@@ -41,7 +41,8 @@ files[] = tests/upgrade/upgrade.test
files[] = tests/upgrade/upgrade.comment.test
files[] = tests/upgrade/upgrade.filter.test
files[] = tests/upgrade/upgrade.forum.test
+files[] = tests/upgrade/upgrade.locale.test
+files[] = tests/upgrade/upgrade.menu.test
files[] = tests/upgrade/upgrade.node.test
files[] = tests/upgrade/upgrade.taxonomy.test
files[] = tests/upgrade/upgrade.upload.test
-files[] = tests/upgrade/upgrade.locale.test
diff --git a/modules/simpletest/tests/upgrade/drupal-6.menu.database.php b/modules/simpletest/tests/upgrade/drupal-6.menu.database.php
new file mode 100644
index 000000000..d10c4eec4
--- /dev/null
+++ b/modules/simpletest/tests/upgrade/drupal-6.menu.database.php
@@ -0,0 +1,10 @@
+<?php
+db_insert('variable')->fields(array(
+ 'name',
+ 'value',
+))
+->values(array(
+ 'name' => 'menu_default_node_menu',
+ 'value' => 's:15:"secondary-links";',
+))
+->execute();
diff --git a/modules/simpletest/tests/upgrade/upgrade.menu.test b/modules/simpletest/tests/upgrade/upgrade.menu.test
new file mode 100644
index 000000000..beb20277a
--- /dev/null
+++ b/modules/simpletest/tests/upgrade/upgrade.menu.test
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * Upgrade test for menu.module.
+ */
+class MenuUpgradePathTestCase extends UpgradePathTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Menu upgrade path',
+ 'description' => 'Menu upgrade path tests.',
+ 'group' => 'Upgrade path',
+ );
+ }
+
+ public function setUp() {
+ // Path to the database dump files.
+ $this->databaseDumpFiles = array(
+ drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php',
+ drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.menu.database.php',
+ );
+ parent::setUp();
+
+ $this->uninstallModulesExcept(array('menu'));
+ }
+
+ /**
+ * Test a successful upgrade.
+ */
+ public function testMenuUpgrade() {
+ $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
+
+ // Test the migration of "Default menu for content" setting to individual node types.
+ $this->drupalGet("admin/structure/types/manage/page/edit");
+ $this->assertNoFieldChecked('edit-menu-options-management', 'Management menu is not selected as available menu');
+ $this->assertNoFieldChecked('edit-menu-options-navigation', 'Navigation menu is not selected as available menu');
+ $this->assertNoFieldChecked('edit-menu-options-primary-links', 'Primary Links menu is not selected as available menu');
+ $this->assertFieldChecked('edit-menu-options-secondary-links', 'Secondary Links menu is selected as available menu');
+ $this->assertNoFieldChecked('edit-menu-options-user-menu', 'User menu is not selected as available menu');
+ $this->assertOptionSelected('edit-menu-parent', 'secondary-links:0', 'Secondary links is selected as default parent item');
+
+ $this->assertEqual(variable_get('menu_default_node_menu'), NULL, 'Redundant variable menu_default_node_menu has been removed');
+
+ }
+}