BlockAdminThemeTest.php in Drupal 9
File
core/modules/block/tests/src/Functional/BlockAdminThemeTest.php
View source
<?php
namespace Drupal\Tests\block\Functional;
use Drupal\Tests\BrowserTestBase;
class BlockAdminThemeTest extends BrowserTestBase {
protected static $modules = [
'block',
'contextual',
];
protected $defaultTheme = 'stark';
public function testAdminTheme() {
$admin_user = $this
->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this
->drupalLogin($admin_user);
$this
->drupalGet('admin/structure/block/list/bartik');
$this
->assertSession()
->statusCodeEquals(403);
\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);
}
public function testSevenAdminTheme() {
$admin_user = $this
->drupalCreateUser([
'access administration pages',
'administer themes',
'access contextual links',
'view the administration theme',
]);
$this
->drupalLogin($admin_user);
\Drupal::service('theme_installer')
->install([
'seven',
]);
$edit['admin_theme'] = 'seven';
$this
->drupalGet('admin/appearance');
$this
->submitForm($edit, 'Save configuration');
$settings = [
'theme' => 'seven',
'region' => 'header',
];
$block = $this
->drupalPlaceBlock('local_tasks_block', $settings);
$this
->drupalGet('admin');
$this
->assertSession()
->responseNotContains('<div data-contextual-id="block:block=' . $block
->id() . ':langcode=en"></div>');
$this
->assertSession()
->responseNotContains('contextual-region');
}
}