You are here

function i18nMenuTestCase::testMenuTranslateLocalize in Internationalization 7

File

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

Class

i18nMenuTestCase
@file Test case for multilingual menus.

Code

function testMenuTranslateLocalize() {

  // Test filtering for menu blocks.
  $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,
  ));
  $block['title'] = $menu['title'];
  $block['module'] = 'menu';
  $block['delta'] = $menu['menu_name'];
  $this
    ->moveBlockToRegion($block, 'sidebar_first');
  $this
    ->drupalGet('<front>');
  $this
    ->assertText($neutral_item['link_title']);
  $this
    ->assertText($default_item['link_title']);
  $this
    ->assertNoText($secondary_item['link_title']);
  $this
    ->i18nGet($this->secondary_language, '<front>');
  $this
    ->assertText($neutral_item['link_title']);
  $this
    ->assertNoText($default_item['link_title']);
  $this
    ->assertText($secondary_item['link_title']);

  // Test filtering for built-in menus.
  $edit = array(
    'i18n_mode' => I18N_MODE_MULTIPLE,
  );
  $this
    ->drupalPost('admin/structure/menu/manage/main-menu/edit', $edit, t('Save'));
  $neutral_item = $this
    ->createMenuLink(array(
    'menu_name' => 'main-menu',
  ));
  $default_item = $this
    ->createMenuLink(array(
    'menu_name' => 'main-menu',
    'language' => $this->default_language,
  ));
  $secondary_item = $this
    ->createMenuLink(array(
    'menu_name' => 'main-menu',
    'language' => $this->secondary_language,
  ));
  $this
    ->drupalGet('<front>');
  $this
    ->assertText($neutral_item['link_title']);
  $this
    ->assertText($default_item['link_title']);
  $this
    ->assertNoText($secondary_item['link_title']);
  $this
    ->i18nGet($this->secondary_language, '<front>');
  $this
    ->assertText($neutral_item['link_title']);
  $this
    ->assertNoText($default_item['link_title']);
  $this
    ->assertText($secondary_item['link_title']);

  // Test the same thing with a system menu used as a block.
  $block['title'] = $menu['title'];
  $block['module'] = 'system';
  $block['delta'] = 'main-menu';
  $this
    ->moveBlockToRegion($block, 'sidebar_first');
  $this
    ->drupalGet('<front>');
  $this
    ->assertText($neutral_item['link_title']);
  $this
    ->assertText($default_item['link_title']);
  $this
    ->assertNoText($secondary_item['link_title']);
  $this
    ->i18nGet($this->secondary_language, '<front>');
  $this
    ->assertText($neutral_item['link_title']);
  $this
    ->assertNoText($default_item['link_title']);
  $this
    ->assertText($secondary_item['link_title']);
}