You are here

function EntityTranslationMenuTranslationTestCase::testMenuTranslation in Entity Translation 7

Test if menu translation works with separate menu items.

File

entity_translation_i18n_menu/entity_translation_i18n_menu.test, line 224
Tests for Entity translation module.

Class

EntityTranslationMenuTranslationTestCase
Tests for the translation of menu items on entity forms.

Code

function testMenuTranslation() {

  // Create Basic page in English.
  $link_title_en = $this
    ->randomName();
  $node = $this
    ->createPage($link_title_en, NULL, 'en');

  // Submit translation in Spanish.
  $link_title_es = $this
    ->randomName();
  $node_translation = $this
    ->createTranslation($node, $link_title_es, NULL, 'es', TRUE);

  // Check menu links in both languages.
  $this
    ->get('en', '<front>');
  $this
    ->assertText($link_title_en);
  $this
    ->get('es', '<front>');
  $this
    ->assertText($link_title_es);

  // Edit English menu link.
  $link_title_en2 = $this
    ->randomName();
  $this
    ->editPage($node, $link_title_en, $link_title_en2, 'en');

  // Check that Spanish menu link has not changed.
  $this
    ->get('es', '<front>');
  $this
    ->assertText($link_title_es);

  // Edit Spanish menu link.
  $link_title_es2 = $this
    ->randomName();
  $this
    ->editPage($node, $link_title_es, $link_title_es2, 'es');

  // Check that English menu link has not changed.
  $this
    ->get('en', '<front>');
  $this
    ->assertText($link_title_en2);

  // Add another translation, and check that other menu items are not
  // affected. See https://drupal.org/node/1982140
  $link_title_it = $this
    ->randomName();
  $node_translation = $this
    ->createTranslation($node, $link_title_it, NULL, 'it', NULL);

  // Check that Spanish and English menu links have not changed.
  $this
    ->get('es', '<front>');
  $this
    ->assertText($link_title_es2);
  $this
    ->get('en', '<front>');
  $this
    ->assertText($link_title_en2);

  // Delete Spanish translation and check that the respective menu item has
  // been deleted as well.
  $this
    ->removeTranslation($node, 'es');
  $this
    ->get('es', '<front>');
  $this
    ->assertNoText($link_title_es2);
}