- Rolled back.
parent
258fc5ff7b
commit
a73fabfacd
|
@ -1691,6 +1691,22 @@ function menu_set_custom_theme() {
|
||||||
menu_get_custom_theme(TRUE);
|
menu_get_custom_theme(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a list of named menus.
|
||||||
|
*/
|
||||||
|
function menu_get_names() {
|
||||||
|
$names = &drupal_static(__FUNCTION__);
|
||||||
|
|
||||||
|
if (empty($names)) {
|
||||||
|
$names = db_select('menu_links')
|
||||||
|
->distinct()
|
||||||
|
->fields('menu_links', array('menu_name'))
|
||||||
|
->orderBy('menu_name')
|
||||||
|
->execute()->fetchCol();
|
||||||
|
}
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array containing the names of system-defined (default) menus.
|
* Return an array containing the names of system-defined (default) menus.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -247,6 +247,31 @@ class MenuRouterTestCase extends DrupalWebTestCase {
|
||||||
$this->assertLink(t('Menu link #2'), 0, t('Found menu link #2'));
|
$this->assertLink(t('Menu link #2'), 0, t('Found menu link #2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test menu_get_names().
|
||||||
|
*/
|
||||||
|
function testMenuGetNames() {
|
||||||
|
// Create three menu items.
|
||||||
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
$menu_link = array(
|
||||||
|
'link_title' => 'Menu link #' . $i,
|
||||||
|
'link_path' => 'menu_test/' . $i,
|
||||||
|
'module' => 'menu_test',
|
||||||
|
'menu_name' => 'menu_test_' . $i,
|
||||||
|
);
|
||||||
|
menu_link_save($menu_link);
|
||||||
|
}
|
||||||
|
|
||||||
|
drupal_static_reset('menu_get_names');
|
||||||
|
|
||||||
|
// Verify that the menu names are correctly reported by menu_get_names().
|
||||||
|
$menu_names = menu_get_names();
|
||||||
|
$this->pass(implode(' | ', $menu_names));
|
||||||
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
$this->assertTrue(in_array('menu_test_' . $i, $menu_names), t('Expected menu name %expected is returned.', array('%expected' => 'menu_test_' . $i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for menu_name parameter for hook_menu().
|
* Tests for menu_name parameter for hook_menu().
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue