3 namespace Drupal\Tests\block\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests the block system with admin themes.
12 class BlockAdminThemeTest extends BrowserTestBase {
19 public static $modules = ['block', 'contextual'];
22 * Check for the accessibility of the admin theme on the block admin page.
24 public function testAdminTheme() {
25 // Create administrative user.
26 $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
27 $this->drupalLogin($admin_user);
29 // Ensure that access to block admin page is denied when theme is not
31 $this->drupalGet('admin/structure/block/list/bartik');
32 $this->assertResponse(403);
34 // Install admin theme and confirm that tab is accessible.
35 \Drupal::service('theme_handler')->install(['bartik']);
36 $edit['admin_theme'] = 'bartik';
37 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
38 $this->drupalGet('admin/structure/block/list/bartik');
39 $this->assertResponse(200);
43 * Ensure contextual links are disabled in Seven theme.
45 public function testSevenAdminTheme() {
46 // Create administrative user.
47 $admin_user = $this->drupalCreateUser([
48 'access administration pages',
50 'access contextual links',
51 'view the administration theme',
53 $this->drupalLogin($admin_user);
55 // Install admin theme and confirm that tab is accessible.
56 \Drupal::service('theme_handler')->install(['seven']);
57 $edit['admin_theme'] = 'seven';
58 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
60 // Define our block settings.
67 $block = $this->drupalPlaceBlock('local_tasks_block', $settings);
70 $this->drupalGet('admin');
72 // Check if contextual link classes are unavailable.
73 $this->assertNoRaw('<div data-contextual-id="block:block=' . $block->id() . ':langcode=en"></div>');
74 $this->assertNoRaw('contextual-region');