You are here

protected function ConfigTranslationListUiTest::doMenuListTest in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doMenuListTest()

Tests the menu listing for the translate operation.

1 call to ConfigTranslationListUiTest::doMenuListTest()
ConfigTranslationListUiTest::testTranslateOperationInListUi in core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
Tests if translate link is added to operations in all configuration lists.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php, line 119

Class

ConfigTranslationListUiTest
Visit all lists.

Namespace

Drupal\Tests\config_translation\Functional

Code

protected function doMenuListTest() {

  // Create a test menu to decouple looking for translate operations link so
  // this does not test more than necessary.
  $this
    ->drupalGet('admin/structure/menu/add');

  // Lowercase the machine name.
  $menu_name = mb_strtolower($this
    ->randomMachineName(16));
  $label = $this
    ->randomMachineName(16);
  $edit = [
    'id' => $menu_name,
    'description' => '',
    'label' => $label,
  ];

  // Create the menu by posting the form.
  $this
    ->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));

  // Get the Menu listing.
  $this
    ->drupalGet('admin/structure/menu');
  $translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate';

  // Test if the link to translate the menu is on the page.
  $this
    ->assertLinkByHref($translate_link);

  // Check if the Link is not added if you are missing 'translate
  // configuration' permission.
  $permissions = [
    'administer menu',
  ];
  $this
    ->drupalLogin($this
    ->drupalCreateUser($permissions));

  // Get the Menu listing.
  $this
    ->drupalGet('admin/structure/menu');
  $translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate';

  // Test if the link to translate the menu is NOT on the page.
  $this
    ->assertNoLinkByHref($translate_link);

  // Log in as Admin again otherwise the rest will fail.
  $this
    ->drupalLogin($this->adminUser);

  // Test if the link to translate actually goes to the translate page.
  $this
    ->drupalGet($translate_link);
  $this
    ->assertRaw('<th>' . t('Language') . '</th>');
}