upgrade.menu.test 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Upgrade test for menu.module.
  4. */
  5. class MenuUpgradePathTestCase extends UpgradePathTestCase {
  6. public static function getInfo() {
  7. return array(
  8. 'name' => 'Menu upgrade path',
  9. 'description' => 'Menu upgrade path tests.',
  10. 'group' => 'Upgrade path',
  11. );
  12. }
  13. public function setUp() {
  14. // Path to the database dump files.
  15. $this->databaseDumpFiles = array(
  16. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php',
  17. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.menu.database.php',
  18. );
  19. parent::setUp();
  20. $this->uninstallModulesExcept(array('menu'));
  21. }
  22. /**
  23. * Test a successful upgrade.
  24. */
  25. public function testMenuUpgrade() {
  26. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  27. // Test the migration of "Default menu for content" setting to individual
  28. // node types.
  29. $this->drupalGet('admin/structure/types/manage/page/edit');
  30. $this->assertNoFieldChecked('edit-menu-options-management', 'Management menu is not selected as available menu');
  31. $this->assertNoFieldChecked('edit-menu-options-navigation', 'Navigation menu is not selected as available menu');
  32. $this->assertNoFieldChecked('edit-menu-options-main-menu', 'Main menu is not selected as available menu');
  33. $this->assertFieldChecked('edit-menu-options-secondary-menu', 'Secondary menu is selected as available menu');
  34. $this->assertNoFieldChecked('edit-menu-options-user-menu', 'User menu is not selected as available menu');
  35. $this->assertOptionSelected('edit-menu-parent', 'secondary-menu:0', 'Secondary menu is selected as default parent item');
  36. $this->assertEqual(variable_get('menu_default_node_menu'), NULL, 'Redundant variable menu_default_node_menu has been removed');
  37. // Verify Primary/Secondary Links have been renamed.
  38. $this->drupalGet('admin/structure/menu');
  39. $this->assertNoLinkByHref('admin/structure/menu/manage/primary-links');
  40. $this->assertLinkByHref('admin/structure/menu/manage/main-menu');
  41. $this->assertNoLinkByHref('admin/structure/menu/manage/secondary-links');
  42. $this->assertLinkByHref('admin/structure/menu/manage/secondary-menu');
  43. // Verify the existence of all system-defined (default) menus.
  44. foreach (menu_list_system_menus() as $menu_name => $title) {
  45. $this->assertLinkByHref('admin/structure/menu/manage/' . $menu_name, 0, 'Found default menu: ' . $title);
  46. }
  47. // Verify a few known links are still present, plus the ones created here.
  48. $test_menus = array(
  49. 'navigation' => array('Add content', 'nodeadd-navigation'),
  50. 'management' => array('Administration', 'Account settings'),
  51. 'user-menu' => array('My account', 'Log out'),
  52. 'main-menu' => array('nodeadd-primary'),
  53. 'secondary-menu' => array('nodeadd-secondary'),
  54. );
  55. foreach ($test_menus as $menu_name => $links) {
  56. $this->drupalGet('admin/structure/menu/manage/' . $menu_name);
  57. $this->assertResponse(200, 'Access menu management for ' . $menu_name);
  58. foreach ($links as $link_text) {
  59. $this->assertLink(t($link_text));
  60. }
  61. }
  62. // Check the "source for primary/secondary links" setting.
  63. $this->drupalGet('admin/structure/menu/settings');
  64. $this->assertOptionSelected('edit-menu-main-links-source', 'secondary-menu');
  65. $this->assertOptionSelected('edit-menu-secondary-links-source', 'main-menu');
  66. // Check that both primary/secondary links blocks are visible.
  67. $this->drupalGet('node');
  68. $this->assertText('My Primary Links', '(Formerly) Primary Links block is still visible');
  69. $this->assertText('My Secondary Links', '(Formerly) Secondary Links block is still visible');
  70. }
  71. }