function ThemeUiTest::testModulePermissions

Same name in other branches
  1. 9 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()
  3. 11.x 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 45

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

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