You are here

public function ModulesListFormWebTest::testModulesListFormStatusMessage in Drupal 10

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 \Drupal\system\Form\ModulesListForm.

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')]");
}