1 menu_language.test | public MenuLanguageTestCase::testMenuParentLanguageNode() |
Test that the available parent menu items match on the node form.
File
- core/
modules/ menu/ tests/ menu_language.test, line 159 - Tests for menu.module.
Class
- MenuLanguageTestCase
- Functional tests for multilingual menu items.
Code
public function testMenuParentLanguageNode() {
// Create basic content type.
$this->backdropCreateContentType(array(
'type' => 'page',
'name' => 'Page',
));
// Function backdropCreateContentType is not able to set these values, so we
// set them via config.
$config = config('node.type.page');
$config->set('settings.language', 1);
$config->set('settings.menu_options', array('main-menu' => 'main-menu'));
$config->set('settings.menu_parent', 'main-menu:0');
$config->save();
foreach ($this->langcodes as $langcode) {
$title = 'Node title ' . strtoupper($langcode);
$edit = array(
'title' => $title,
'langcode' => $langcode,
'menu[enabled]' => TRUE,
'menu[link_title]' => $title,
);
$this->backdropPost('node/add/page', $edit, t('Save'));
$node = $this->backdropGetNodeByTitle($title);
$options = array();
if ($langcode == 'en') {
// Make sure that the interface language does not match the langcode.
$options['language'] = language_load('es');
}
$this->backdropGet('node/' . $node->nid . '/edit', $options);
// The available parents must match the node langcode, not the interface
// language.
$available_mlids = array();
$option_values = $this->xpath('//select[@id="edit-menu-parent"]//option/@value');
foreach ($option_values as $value) {
$string = (string) $value;
// We do not need the menu itself.
if ($string == 'main-menu:0') {
continue;
}
$available_mlids[] = str_replace('main-menu:', '', $string);
}
$valid = $this->validateParentOptions($available_mlids, $langcode, $title);
$this->assertTrue($valid, format_string('The parent options contain all valid parents for node %node_title (langcode %langcode)', array(
'%node_title' => $title,
'%langcode' => $langcode,
)));
}
}