function EntityTranslationMenuTranslationTestCase::testMenuLocalization in Entity Translation 7
Test if menu localization works.
File
- entity_translation_i18n_menu/
entity_translation_i18n_menu.test, line 142 - Tests for Entity translation module.
Class
- EntityTranslationMenuTranslationTestCase
- Tests for the translation of menu items on entity forms.
Code
function testMenuLocalization() {
// Create Basic page in English.
$link_title_en = $this
->randomName();
$link_description_en = $this
->randomName() . ' & htmlentity';
$node = $this
->createPage($link_title_en, $link_description_en, 'en');
// Submit translation in Spanish.
$link_title_es = $this
->randomName();
$link_description_es = $this
->randomName() . ' & htmlentity';
$node_translation = $this
->createTranslation($node, $link_title_es, $link_description_es, 'es');
// Check menu links in both languages.
$this
->get('en', '<front>');
$this
->assertLinkWithTitleAttribute($link_title_en, $link_description_en);
$this
->get('es', '<front>');
$this
->assertLinkWithTitleAttribute($link_title_es, $link_description_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
->assertLinkWithTitleAttribute($link_title_es, $link_description_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 changed.
$this
->get('en', '<front>');
$this
->assertLinkWithTitleAttribute($link_title_en2, $link_description_en);
// Check that Spanish menu link has changed.
$this
->get('es', '<front>');
$this
->assertLinkWithTitleAttribute($link_title_es2, $link_description_es);
// 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);
}