diff --git modules/simpletest/tests/menu.test modules/simpletest/tests/menu.test index f46b81d..6940677 100644 --- modules/simpletest/tests/menu.test +++ modules/simpletest/tests/menu.test @@ -489,6 +489,27 @@ class MenuRouterTestCase extends DrupalWebTestCase { $this->drupalGet("menu-test/arguments/$arg1/$arg2/task"); $this->assertRaw($expected, t('Inherited load arguments found.')); } + + /** + * Test if defined load functions are found. + */ + function testMenuLoadFunctions() { + $content = $this->drupalGet('menu-test/load-functions/my-param'); + $this->assertText('Load functions test. ', 'Menu item found.'); + $this->assertText('menu_test_load_functions_load', 'Load function found'); + } + + /** + * Test if defined load functions are found even if parent declares + * "load arguments". + * + * @link http://drupal.org/node/979958 + */ + function testMenuLoadFunctionsWithParentLoadArguments() { + $content = $this->drupalGet('menu-test/load-functions/arguments/my-param'); + $this->assertText('Child: Load function / argument inheritance test.', 'Menu item found.'); + $this->assertText('menu_test_load_functions_load', 'Load function found'); + } } /** diff --git modules/simpletest/tests/menu_test.module modules/simpletest/tests/menu_test.module index 4d673e8..ff96133 100644 --- modules/simpletest/tests/menu_test.module +++ modules/simpletest/tests/menu_test.module @@ -280,6 +280,28 @@ function menu_test_menu() { 'type' => MENU_LOCAL_TASK, ); + // Load function test. + $items['menu-test/load-functions/%menu_test_load_functions'] = array( + 'title' => 'Load functions test.', + 'page callback' => 'menu_test_load_functions', + 'page arguments' => array(2), + 'access callback' => TRUE, + ); + // Parent with load arguments + $items['menu-test/load-functions/arguments'] = array( + 'title' => 'Parent: Load function / argument inheritance test.', + 'page callback' => 'menu_test_load_functions', + 'page arguments' => array(2), + 'access callback' => TRUE, + 'load arguments' => array(2), + ); + $items['menu-test/load-functions/arguments/%menu_test_load_functions'] = array( + 'title' => 'Child: Load function / argument inheritance test.', + 'page callback' => 'menu_test_load_functions', + 'page arguments' => array(3), + 'access callback' => TRUE, + ); + return $items; } @@ -325,6 +347,31 @@ function menu_test_callback() { } /** + * Page callback for the 'load functions' test. + * + * @return + * Names of the load functions or "No load functions found." if none are + * found. + */ +function menu_test_load_functions() { + $item = menu_get_item(); + if (!isset($item['load_functions']) || !count($item['load_functions'])) { + return 'No load functions found.'; + } + return print_r($item['load_functions'], true); +} + +/** + * Dummy load function for the 'load functions' test. + * + * @return + * A random string. + */ +function menu_test_load_functions_load() { + return ''; +} + +/** * Page callback to use when testing the theme callback functionality. * * @param $inherited