summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-11-20 07:18:59 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-11-20 07:18:59 +0000
commit328982747d916971c6309d7f3b453c5b3ec4891b (patch)
tree7796731a6f0521d86ce228b981e5e2c8b76a1597
parentb47ecd8ad7a8a961b5d06139b2fa3db62b7f09ad (diff)
downloadbrdo-328982747d916971c6309d7f3b453c5b3ec4891b.tar.gz
brdo-328982747d916971c6309d7f3b453c5b3ec4891b.tar.bz2
#293514 by mikey_p: Add tests for menu_rebuild_needed.
-rw-r--r--modules/simpletest/tests/menu.test44
1 files changed, 38 insertions, 6 deletions
diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test
index ca674248f..c2a0e63e1 100644
--- a/modules/simpletest/tests/menu.test
+++ b/modules/simpletest/tests/menu.test
@@ -7,9 +7,6 @@
*/
class MenuIncTestCase extends DrupalWebTestCase {
- /**
- * Implementation of getInfo().
- */
function getInfo() {
return array(
'name' => t('Hook menu tests'),
@@ -18,9 +15,6 @@ class MenuIncTestCase extends DrupalWebTestCase {
);
}
- /**
- * Implementation of setUp().
- */
function setUp() {
// Enable dummy module that implements hook_menu.
parent::setUp('hook_menu');
@@ -45,3 +39,41 @@ class MenuIncTestCase extends DrupalWebTestCase {
$this->assertEqual($name, 'changed', t('Menu name was successfully changed after rebuild.'));
}
}
+
+/**
+ * Tests rebuilding the menu by setting 'menu_rebuild_needed.'
+ */
+class MenuRebuildTestCase extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Menu rebuild test'),
+ 'description' => t('Test rebuilding of menu.'),
+ 'group' => t('Menu'),
+ );
+ }
+
+ /**
+ * Test if the 'menu_rebuild_needed' variable triggers a menu_rebuild() call.
+ */
+ function testMenuRebuildByVariable() {
+ // Check if 'admin' path exists.
+ $admin_exists = db_result(db_query("SELECT path from {menu_router} WHERE path = 'admin'"));
+ $this->assertEqual($admin_exists, 'admin', t("The path 'admin/' exists prior to deleting."));
+
+ // Delete the path item 'admin', and test that the path doesn't exist in the database.
+ $delete = db_delete('menu_router')
+ ->condition('path', 'admin')
+ ->execute();
+ $admin_exists = db_result(db_query("SELECT path from {menu_router} WHERE path = 'admin'"));
+ $this->assertFalse($admin_exists, t("The path 'admin/' has been deleted and doesn't exist in the database."));
+
+ // Now we enable the rebuild variable and trigger menu_execute_active_handler()
+ // to rebuild the menu item. Now 'admin' should exist.
+ variable_set('menu_rebuild_needed', TRUE);
+ // menu_execute_active_handler() should trigger the rebuild.
+ $this->drupalGet('<front>');
+ $admin_exists = db_result(db_query("SELECT path from {menu_router} WHERE path = 'admin'"));
+ $this->assertEqual($admin_exists, 'admin', t("The menu has been rebuilt, the path 'admin' now exists again."));
+ }
+
+}