You are here

public function MenuMultilingualTest::testViewsMenuItemUntranslated in Menu Multilingual 8

Test for View untranslated Menu Items.

File

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

Class

MenuMultilingualTest
Class MenuMultilingualTest.

Namespace

Drupal\Tests\menu_multilingual\Functional

Code

public function testViewsMenuItemUntranslated() {

  // Create 4 translated custom menu links in the main menu.
  $this
    ->createViewsMenuItemUntranslated();
  $session = $this
    ->assertSession();

  // Test defaults without any configurations.
  $this
    ->drupalGet('node');
  $session
    ->pageTextContains('Views English menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextContains('Views 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('Views English menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextNotContains('Views 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('Views English menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextNotContains('Views 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('Views English menu item');
  $this
    ->drupalGet('fr/node');
  $session
    ->pageTextContains('Views English menu item');
}