public function MenuMultilingualTest::testCustomMenuItemLanguageNotApplicable in Menu Multilingual 8
Test for Custom Menu Items with Language Not Applicable.
File
- tests/
src/ Functional/ MenuMultilingualTest.php, line 302
Class
- MenuMultilingualTest
- Class MenuMultilingualTest.
Namespace
Drupal\Tests\menu_multilingual\FunctionalCode
public function testCustomMenuItemLanguageNotApplicable() {
// Create 4 translated custom menu links in the main menu.
$this
->createCustomMenuItemLanguageNotApplicable('Node 1 translated', 1);
$this
->createCustomMenuItemLanguageNotApplicable('Node 2 untranslated', 2);
$this
->createCustomMenuItemLanguageNotApplicable('Node 3 Language Not Applicable', 3);
$this
->createCustomMenuItemLanguageNotApplicable('Node 4 Language Not Specified', 4);
$session = $this
->assertSession();
// Test defaults without any configurations.
$this
->drupalGet('node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextContains('Node 4 Language Not Specified, Language Not Applicable menu item');
$this
->drupalGet('fr/node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextContains('Node 4 Language Not Specified, Language Not Applicable menu item');
// Test 'Hide menu items without translated label'.
$edit = [
'settings[only_translated_labels]' => 1,
'settings[only_translated_content]' => 0,
];
$this
->drupalGet($this->menuBlockConfigPath);
$this
->submitForm($edit, 'Save block');
$this
->drupalGet('node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextContains('Node 4 Language Not Specified, Language Not Applicable menu item');
$this
->drupalGet('fr/node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextContains('Node 4 Language Not Specified, Language Not Applicable menu item');
// Test 'Hide menu items without translated label' and
// 'Hide menu items without translated content'.
$edit = [
'settings[only_translated_labels]' => 1,
'settings[only_translated_content]' => 1,
];
$this
->drupalGet($this->menuBlockConfigPath);
$this
->submitForm($edit, 'Save block');
$this
->drupalGet('node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, Language Not Applicable menu item');
$this
->drupalGet('fr/node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextNotContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, Language Not Applicable menu item');
// Test 'Hide menu items without translated content'.
$edit = [
'settings[only_translated_labels]' => 0,
'settings[only_translated_content]' => 1,
];
$this
->drupalGet($this->menuBlockConfigPath);
$this
->submitForm($edit, 'Save block');
$this
->drupalGet('node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, Language Not Applicable menu item');
$this
->drupalGet('fr/node');
$session
->pageTextContains('Node 1 translated, Language Not Applicable menu item');
$session
->pageTextNotContains('Node 2 untranslated, Language Not Applicable menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, Language Not Applicable menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, Language Not Applicable menu item');
}