function ModulesListFormWebTest::testModulesListFormStatusMessage

Same name and namespace in other branches
  1. 10 core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormStatusMessage()
  2. 11.x core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest::testModulesListFormStatusMessage()

Tests the status message when enabling one or more modules.

File

core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php, line 68

Class

ModulesListFormWebTest
Tests <a href="/api/drupal/core%21modules%21system%21src%21Form%21ModulesListForm.php/class/ModulesListForm/9" title="Provides module installation interface." class="local">\Drupal\system\Form\ModulesListForm</a>.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testModulesListFormStatusMessage() {
    $this->drupalGet('admin/modules');
    // Enable a module that does not define permissions.
    $edit = [
        'modules[layout_discovery][enable]' => 'layout_discovery',
    ];
    $this->submitForm($edit, 'Install');
    $this->assertSession()
        ->elementTextContains('xpath', "//div[@role='contentinfo' and h2[text()='Status message']]", 'Module Layout Discovery has been enabled.');
    $this->assertSession()
        ->elementNotExists('xpath', "//div[@role='contentinfo' and h2[text()='Status message']]//a");
    // Enable a module that defines permissions.
    $edit = [
        'modules[action][enable]' => 'action',
    ];
    $this->submitForm($edit, 'Install');
    $this->assertSession()
        ->elementTextContains('xpath', "//div[@role='contentinfo' and h2[text()='Status message']]", 'Module Actions has been enabled.');
    $this->assertSession()
        ->elementExists('xpath', "//div[@role='contentinfo' and h2[text()='Status message']]//a[contains(@href, '/admin/people/permissions/module/action')]");
    // Enable a module that has dependencies and both define permissions.
    $edit = [
        'modules[content_moderation][enable]' => 'content_moderation',
    ];
    $this->submitForm($edit, 'Install');
    $this->submitForm([], 'Continue');
    $this->assertSession()
        ->elementTextContains('xpath', "//div[@role='contentinfo' and h2[text()='Status message']]", '2 modules have been enabled: Content Moderation, Workflows.');
    $this->assertSession()
        ->elementExists('xpath', "//div[@role='contentinfo' and h2[text()='Status message']]//a[contains(@href, '/admin/people/permissions/module/content_moderation%2Cworkflows')]");
}

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