1 menu_language.test | public MenuLanguageTestCase::testMenuParentLanguage() |
Test menu item parents on form menu_edit_item.
File
- core/
modules/ menu/ tests/ menu_language.test, line 121 - Tests for menu.module.
Class
- MenuLanguageTestCase
- Functional tests for multilingual menu items.
Code
public function testMenuParentLanguage() {
foreach ($this->langcodes as $langcode) {
$options = array(
'query' => array('langcode' => $langcode),
);
if ($langcode == 'en') {
// Make sure that the interface language does not match the langcode.
$options['language'] = language_load('es');
}
$this->backdropGet('admin/structure/menu/manage/main-menu/add', $options);
$item_langcodes = $this->xpath('//select[@id="edit-langcode"]//option[@selected]/@value');
// The url parameter also sets the menu item language.
$this->assertTrue((string) $item_langcodes[0] == $langcode, 'The item langcode list has the right value selected');
// We do not need the menus (top level).
$top_level = array('main-menu:0', 'management:0', 'user-menu:0');
$option_values = $this->xpath('//select[@id="edit-parent"]//option/@value');
$available_mlids = array();
foreach ($option_values as $value) {
$string = (string) $value;
if (in_array($string, $top_level)) {
continue;
}
$available_mlids[] = str_replace('main-menu:', '', $string);
}
$valid = $this->validateParentOptions($available_mlids, $langcode);
$this->assertTrue($valid, format_string('The parent options contain all valid parents for this menu item (langcode %langcode)', array(
'%langcode' => $langcode,
)));
}
}