You are here

public function BlockAdminThemeTest::testAdminTheme in Drupal 9

Same name and namespace in other branches
  1. 8 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() {

  // 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/bartik');
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Install admin theme and confirm that tab is accessible.
  \Drupal::service('theme_installer')
    ->install([
    'bartik',
  ]);
  $edit['admin_theme'] = 'bartik';
  $this
    ->drupalGet('admin/appearance');
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->drupalGet('admin/structure/block/list/bartik');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}