public function MenuMultilingualTest::testCustomMenuItemUntranslated in Menu Multilingual 8
Test for untranslated Custom Menu Items.
File
- tests/
src/ Functional/ MenuMultilingualTest.php, line 219
Class
- MenuMultilingualTest
- Class MenuMultilingualTest.
Namespace
Drupal\Tests\menu_multilingual\FunctionalCode
public function testCustomMenuItemUntranslated() {
// Create 4 translated custom menu links in the main menu.
$this
->createCustomMenuItemUntranslated('Node 1 translated', 1);
$this
->createCustomMenuItemUntranslated('Node 2 untranslated', 2);
$this
->createCustomMenuItemUntranslated('Node 3 Language Not Applicable', 3);
$this
->createCustomMenuItemUntranslated('Node 4 Language Not Specified', 4);
$session = $this
->assertSession();
// Test defaults without any configurations.
$this
->drupalGet('node');
$session
->pageTextContains('Node 1 translated, English menu item');
$session
->pageTextContains('Node 2 untranslated, English menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextContains('Node 4 Language Not Specified, English menu item');
$this
->drupalGet('fr/node');
$session
->pageTextContains('Node 1 translated, English menu item');
$session
->pageTextContains('Node 2 untranslated, English menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextContains('Node 4 Language Not Specified, English 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, English menu item');
$session
->pageTextContains('Node 2 untranslated, English menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextContains('Node 4 Language Not Specified, English menu item');
$this
->drupalGet('fr/node');
$session
->pageTextNotContains('Node 1 translated, English menu item');
$session
->pageTextNotContains('Node 2 untranslated, English menu item');
$session
->pageTextNotContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, English 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, English menu item');
$session
->pageTextContains('Node 2 untranslated, English menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, English menu item');
$this
->drupalGet('fr/node');
$session
->pageTextNotContains('Node 1 translated, English menu item');
$session
->pageTextNotContains('Node 2 untranslated, English menu item');
$session
->pageTextNotContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, English 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, English menu item');
$session
->pageTextContains('Node 2 untranslated, English menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, English menu item');
$this
->drupalGet('fr/node');
$session
->pageTextContains('Node 1 translated, English menu item');
$session
->pageTextNotContains('Node 2 untranslated, English menu item');
$session
->pageTextContains('Node 3 Language Not Applicable, English menu item');
$session
->pageTextNotContains('Node 4 Language Not Specified, English menu item');
}