Index: modules/simpletest/tests/menu.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/menu.test,v retrieving revision 1.3 diff -u -p -r1.3 menu.test --- modules/simpletest/tests/menu.test 20 Nov 2008 07:18:59 -0000 1.3 +++ modules/simpletest/tests/menu.test 26 Dec 2008 14:04:13 -0000 @@ -77,3 +77,36 @@ class MenuRebuildTestCase extends Drupal } } + +/** + * Testcase for the menu_set_item() function. + */ +class MenuSetItemTestCase extends DrupalWebTestCase { + function getInfo() { + return array( + 'name' => t('Function menu_set_item test.'), + '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'] = $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'); + } + +}