I have a custom menu profile-menu
and have configured a block to display that menu. It has four menu items with 'expanded' => TRUE
. However, during test runs these expanded menu items do not show as expanded. I've dug through the Drupal menu code and it looks like Drupal won't handle 'expanded'
unless the variable 'menu_expanded'
includes the menu name, which is odd because I've never had this problem outside of the test environment. I tried adding variable_set('menu_expanded', array('profile-menu'))
to hook_install
but for whatever reason when I call variable_get('menu_expanded')
inside the test case that variable is an empty array.
If during the test case I call menu_cache_clear_all(); variable_set('menu_expanded', array('profile-menu'))
, everything does work as expected. The code that seems to be gated by this variable is in menu_tree_page_data
.
What's the right way to make sure certain menu items (which I have defined myself in hook_menu
) are always expanded? Because setting expanded => TRUE
in hook_menu
apparently doesn't cut it during test cases. Also, why am I only seeing this issue when running test cases?