function BlockAdminThemeTest::testAdminTheme

Same name in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockAdminThemeTest.php \Drupal\Tests\block\Functional\BlockAdminThemeTest::testAdminTheme()
  2. 8.9.x core/modules/block/tests/src/Functional/BlockAdminThemeTest.php \Drupal\Tests\block\Functional\BlockAdminThemeTest::testAdminTheme()
  3. 10 core/modules/block/tests/src/Functional/BlockAdminThemeTest.php \Drupal\Tests\block\Functional\BlockAdminThemeTest::testAdminTheme()

Check for the accessibility of the admin theme on the block admin page.

File

core/modules/block/tests/src/Functional/BlockAdminThemeTest.php, line 29

Class

BlockAdminThemeTest
Tests the block system with admin themes.

Namespace

Drupal\Tests\block\Functional

Code

public function testAdminTheme() : void {
    // Create administrative user.
    $admin_user = $this->drupalCreateUser([
        'administer blocks',
        'administer themes',
    ]);
    $this->drupalLogin($admin_user);
    // Ensure that access to block admin page is denied when theme is not
    // installed.
    $this->drupalGet('admin/structure/block/list/olivero');
    $this->assertSession()
        ->statusCodeEquals(403);
    // Install admin theme and confirm that tab is accessible.
    \Drupal::service('theme_installer')->install([
        'olivero',
    ]);
    $edit['admin_theme'] = 'olivero';
    $this->drupalGet('admin/appearance');
    $this->submitForm($edit, 'Save configuration');
    $this->drupalGet('admin/structure/block/list/olivero');
    $this->assertSession()
        ->statusCodeEquals(200);
}

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