function ConfigTranslationListUiTest::doMenuListTest

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()
  2. 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doMenuListTest()
  3. 10 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 127

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 = $this->randomMachineName(16);
    $label = $this->randomMachineName(16);
    $edit = [
        'id' => $menu_name,
        'description' => '',
        'label' => $label,
    ];
    // Create the menu by posting the form.
    $this->drupalGet('admin/structure/menu/add');
    $this->submitForm($edit, '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->assertSession()
        ->linkByHrefExists($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->assertSession()
        ->linkByHrefNotExists($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->assertSession()
        ->responseContains('<th>Language</th>');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.