From 44aefb0a4e7e7794fc74f0fe48b10fae1b546699 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 2 Dec 2010 17:34:24 +0000 Subject: #979958 by das-peter, Damien Tournoud: Fixed regression in load_functions detection for menu items --- modules/simpletest/tests/menu.test | 62 ++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) (limited to 'modules/simpletest/tests/menu.test') diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test index f46b81df4..c25240e99 100644 --- a/modules/simpletest/tests/menu.test +++ b/modules/simpletest/tests/menu.test @@ -474,20 +474,62 @@ class MenuRouterTestCase extends DrupalWebTestCase { $this->assertTitle($asserted_title . ' | Drupal', t('Menu title is') . ': ' . $asserted_title, 'Menu'); } + /** + * Load the router for a given path. + */ + protected function menuLoadRouter($router_path) { + return db_query('SELECT * FROM {menu_router} WHERE path = :path', array(':path' => $router_path))->fetchAssoc(); + } + /** * Tests inheritance of 'load arguments'. */ function testMenuLoadArgumentsInheritance() { - $arg1 = $this->randomName(); - $arg2 = $this->randomName(); - $expected = print_r(array('%menu_test_argument' => $arg1, '%' => $arg2), TRUE); - - $this->drupalGet("menu-test/arguments/$arg1/$arg2"); - $this->assertRaw($expected, t('Inherited load arguments found.')); - $this->drupalGet("menu-test/arguments/$arg1/$arg2/default"); - $this->assertRaw($expected, t('Inherited load arguments found.')); - $this->drupalGet("menu-test/arguments/$arg1/$arg2/task"); - $this->assertRaw($expected, t('Inherited load arguments found.')); + $expected = array( + 'menu-test/arguments/%/%' => array( + 2 => array('menu_test_argument_load' => array(3)), + 3 => NULL, + ), + // Arguments are inherited to normal children. + 'menu-test/arguments/%/%/default' => array( + 2 => array('menu_test_argument_load' => array(3)), + 3 => NULL, + ), + // Arguments are inherited to tab children. + 'menu-test/arguments/%/%/task' => array( + 2 => array('menu_test_argument_load' => array(3)), + 3 => NULL, + ), + // Arguments are only inherited to the same loader functions. + 'menu-test/arguments/%/%/common-loader' => array( + 2 => array('menu_test_argument_load' => array(3)), + 3 => 'menu_test_other_argument_load', + ), + // Arguments are not inherited to children not using the same loader + // function. + 'menu-test/arguments/%/%/different-loaders-1' => array( + 2 => NULL, + 3 => 'menu_test_argument_load', + ), + 'menu-test/arguments/%/%/different-loaders-2' => array( + 2 => 'menu_test_other_argument_load', + 3 => NULL, + ), + 'menu-test/arguments/%/%/different-loaders-3' => array( + 2 => NULL, + 3 => NULL, + ), + // Explicit loader arguments should not be overriden by parent. + 'menu-test/arguments/%/%/explicit-arguments' => array( + 2 => array('menu_test_argument_load' => array()), + 3 => NULL, + ), + ); + + foreach ($expected as $router_path => $load_functions) { + $router_item = $this->menuLoadRouter($router_path); + $this->assertIdentical(unserialize($router_item['load_functions']), $load_functions, t('Expected load functions for router %router_path' , array('%router_path' => $router_path))); + } } } -- cgit v1.2.3