You are here

protected function ConfigTranslationListUiTest::doMenuListTest in Zircon Profile 8

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

Tests the menu listing for the translate operation.

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

File

core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php, line 113
Contains \Drupal\config_translation\Tests\ConfigTranslationListUiTest.

Class

ConfigTranslationListUiTest
Visit all lists.

Namespace

Drupal\config_translation\Tests

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 = Unicode::strtolower($this
    ->randomMachineName(16));
  $label = $this
    ->randomMachineName(16);
  $edit = array(
    '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 = array(
    '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);

  // Login 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>');
}