comparison core/modules/block/tests/src/Functional/BlockAdminThemeTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\block\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8 * Tests the block system with admin themes.
9 *
10 * @group block
11 */
12 class BlockAdminThemeTest extends BrowserTestBase {
13
14 /**
15 * Modules to install.
16 *
17 * @var array
18 */
19 public static $modules = ['block', 'contextual'];
20
21 /**
22 * Check for the accessibility of the admin theme on the block admin page.
23 */
24 public function testAdminTheme() {
25 // Create administrative user.
26 $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
27 $this->drupalLogin($admin_user);
28
29 // Ensure that access to block admin page is denied when theme is not
30 // installed.
31 $this->drupalGet('admin/structure/block/list/bartik');
32 $this->assertResponse(403);
33
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);
40 }
41
42 /**
43 * Ensure contextual links are disabled in Seven theme.
44 */
45 public function testSevenAdminTheme() {
46 // Create administrative user.
47 $admin_user = $this->drupalCreateUser([
48 'access administration pages',
49 'administer themes',
50 'access contextual links',
51 'view the administration theme',
52 ]);
53 $this->drupalLogin($admin_user);
54
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'));
59
60 // Define our block settings.
61 $settings = [
62 'theme' => 'seven',
63 'region' => 'header',
64 ];
65
66 // Place a block.
67 $block = $this->drupalPlaceBlock('local_tasks_block', $settings);
68
69 // Open admin page.
70 $this->drupalGet('admin');
71
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');
75 }
76
77 }