Index: modules/simpletest/tests/menu.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/menu.test,v retrieving revision 1.2 diff -u -r1.2 menu.test --- modules/simpletest/tests/menu.test 15 Sep 2008 20:48:09 -0000 1.2 +++ modules/simpletest/tests/menu.test 16 Oct 2008 12:01:50 -0000 @@ -45,3 +45,52 @@ $this->assertEqual($name, 'changed', t('Menu name was successfully changed after rebuild.')); } } + +/** + * Testcase for the menu_set_item() function. + * + */ +class MenuSetItemTestCase extends DrupalWebTestCase { + + /** + * Implementation of getInfo(). + * + * @return array + */ + function getInfo() { + return array( + 'name' => t('Test for the menu_set_item() function.'), + 'description' => t('Tests if the menu_set_item function has the desired effects by comparing it to menu_get_item output'), + 'group' => t('Menu'), + ); + } + + /** + * This function gets a menu item, changes it and sets it, then the two results are compared. + * + */ + function testMenuSetItem() { + $original_item = menu_get_item('node'); + + $this->assertEqual($original_item['path'], 'node', t("Path from menu_get_item('node') is equal to 'node'"), 'menu'); + + /** + * Say we want our original path modified for testing purposes, + * we have our existing path 'node' and want to change it to 'node_test' + */ + $original_item['path'] = 'node_test'; + $original_item['href'] = 'node_test'; + + /** + * To make clear this is a testnode, we prefix the title + */ + $original_item['title'] = 'Test: '. $original_item['title']; + + $test_item = menu_set_item('node', $original_item); + + $compare_item = menu_get_item('node'); + + $this->assertEqual($original_item, $compare_item, t('Modified item is equal to newly retrieved item.'), 'menu'); + } +} +