You are here

public function MenuMultilingualTest::testCustomMenuItemLanguageNotSpecified in Menu Multilingual 8

Test for Custom Menu Items with Language Not Specified.

File

tests/src/Functional/MenuMultilingualTest.php, line 385

Class

MenuMultilingualTest
Class MenuMultilingualTest.

Namespace

Drupal\Tests\menu_multilingual\Functional

Code

public function testCustomMenuItemLanguageNotSpecified() {

  // Create 4 translated custom menu links in the main menu.
  $this
    ->createCustomMenuItemLanguageNotSpecified('Node 1 translated', 1);
  $this
    ->createCustomMenuItemLanguageNotSpecified('Node 2 untranslated', 2);
  $this
    ->createCustomMenuItemLanguageNotSpecified('Node 3 Language Not Applicable', 3);
  $this
    ->createCustomMenuItemLanguageNotSpecified('Node 4 Language Not Specified', 4);
  $session = $this
    ->assertSession();

  // Test defaults without any configurations.
  $this
    ->drupalGet('node');
  $session
    ->pageTextContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 4 Language Not Specified, Language Not Specified menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 4 Language Not Specified, Language Not Specified 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
    ->pageTextNotContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 4 Language Not Specified, Language Not Specified menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextNotContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 4 Language Not Specified, Language Not Specified 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
    ->pageTextNotContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 4 Language Not Specified, Language Not Specified menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextNotContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 4 Language Not Specified, Language Not Specified 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 Specified menu item');
  $session
    ->pageTextContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 4 Language Not Specified, Language Not Specified menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextContains('Node 1 translated, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 2 untranslated, Language Not Specified menu item');
  $session
    ->pageTextContains('Node 3 Language Not Applicable, Language Not Specified menu item');
  $session
    ->pageTextNotContains('Node 4 Language Not Specified, Language Not Specified menu item');
}