You are here

public function ThemeUiTest::testModulePermissions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php \Drupal\Tests\system\Functional\Theme\ThemeUiTest::testModulePermissions()
  2. 10 core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php \Drupal\Tests\system\Functional\Theme\ThemeUiTest::testModulePermissions()

Tests permissions for enabling themes depending on disabled modules.

File

core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php, line 46

Class

ThemeUiTest
Tests the theme UI.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testModulePermissions() {

  // Log in as a user without permission to enable modules.
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer themes',
  ]));
  $this
    ->drupalGet('admin/appearance');

  // The links to install a theme that would enable modules should be replaced
  // by this message.
  $this
    ->assertSession()
    ->pageTextContains('This theme requires the listed modules to operate correctly. They must first be enabled by a user with permissions to do so.');

  // The install page should not be reachable.
  $this
    ->drupalGet('admin/appearance/install?theme=test_theme_depending_on_modules');
  $this
    ->assertSession()
    ->statusCodeEquals(404);
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer themes',
    'administer modules',
  ]));
  $this
    ->drupalGet('admin/appearance');
  $this
    ->assertSession()
    ->pageTextNotContains('This theme requires the listed modules to operate correctly. They must first be enabled by a user with permissions to do so.');
}