You are here

function i18nMenuTestCase::testMenuTranslationSets in Internationalization 7

Tests if the translation set management works.

File

i18n_menu/i18n_menu.test, line 157
Test case for multilingual menus.

Class

i18nMenuTestCase
@file Test case for multilingual menus.

Code

function testMenuTranslationSets() {
  $menu = $this
    ->createMenu(array(
    'i18n_mode' => I18N_MODE_MULTIPLE,
  ));
  $neutral_item = $this
    ->createMenuLink(array(
    'menu_name' => $menu['menu_name'],
  ));
  $default_item = $this
    ->createMenuLink(array(
    'menu_name' => $menu['menu_name'],
    'language' => $this->default_language,
  ));
  $secondary_item = $this
    ->createMenuLink(array(
    'menu_name' => $menu['menu_name'],
    'language' => $this->secondary_language,
  ));
  $translationset_edit = array(
    'translations[' . $this->default_language . ']' => $default_item['menu_name'] . ':' . $default_item['mlid'],
    'translations[' . $this->secondary_language . ']' => $secondary_item['menu_name'] . ':' . $secondary_item['mlid'],
  );
  $translation_set = $this
    ->createMenuLinkTranslationSet($translationset_edit);

  // Check if the overview works
  $this
    ->drupalGet('admin/structure/menu/manage/translation');
  $link = $this
    ->xpath('//*/a[contains(@href,"admin/structure/menu/manage/translation/edit/' . $translation_set->tsid . '")]');
  $this
    ->assertTrue(!empty($link), 'Created translation-set found.');

  // Check if the edit mode works
  $this
    ->drupalGet('admin/structure/menu/manage/translation/edit/' . $translation_set->tsid);
  $this
    ->assertFieldByXPath("//*[@id='edit-translations-" . $this->default_language . "']/option[@selected]/@value", $menu['menu_name'] . ':' . $default_item['mlid'], 'Expected option selection for language ' . $this->default_language . ' found.');
  $this
    ->assertFieldByXPath("//*[@id='edit-translations-" . $this->secondary_language . "']/option[@selected]/@value", $menu['menu_name'] . ':' . $secondary_item['mlid'], 'Expected option selection for language ' . $this->secondary_language . ' found.');
}