Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\block\Functional;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Tests\BrowserTestBase;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Tests the block demo page with admin themes.
|
Chris@0
|
9 *
|
Chris@0
|
10 * @group block
|
Chris@0
|
11 */
|
Chris@0
|
12 class BlockDemoTest extends BrowserTestBase {
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * Modules to enable.
|
Chris@0
|
16 *
|
Chris@0
|
17 * @var array
|
Chris@0
|
18 */
|
Chris@0
|
19 public static $modules = ['block'];
|
Chris@0
|
20
|
Chris@0
|
21 /**
|
Chris@0
|
22 * Check for the accessibility of the admin block demo page.
|
Chris@0
|
23 */
|
Chris@0
|
24 public function testBlockDemo() {
|
Chris@0
|
25 // Create administrative user.
|
Chris@0
|
26 $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
|
Chris@0
|
27 $this->drupalLogin($admin_user);
|
Chris@0
|
28
|
Chris@0
|
29 // Confirm we have access to the block demo page for the default theme.
|
Chris@0
|
30 $config = $this->container->get('config.factory')->get('system.theme');
|
Chris@0
|
31 $default_theme = $config->get('default');
|
Chris@0
|
32 $this->drupalGet('admin/structure/block/demo/' . $default_theme);
|
Chris@0
|
33 $this->assertResponse(200);
|
Chris@0
|
34 $this->assertLinkByHref('admin/structure/block');
|
Chris@0
|
35 $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme);
|
Chris@0
|
36
|
Chris@0
|
37 // All available themes in core.
|
Chris@0
|
38 $available_themes = [
|
Chris@0
|
39 'bartik',
|
Chris@0
|
40 'classy',
|
Chris@0
|
41 'seven',
|
Chris@0
|
42 'stark',
|
Chris@0
|
43 ];
|
Chris@0
|
44
|
Chris@0
|
45 // All available themes minute minus the default theme.
|
Chris@0
|
46 $themes = array_diff($available_themes, [$default_theme]);
|
Chris@0
|
47
|
Chris@0
|
48 foreach ($themes as $theme) {
|
Chris@0
|
49 // Install theme.
|
Chris@0
|
50 $this->container->get('theme_handler')->install([$theme]);
|
Chris@0
|
51 // Confirm access to the block demo page for the theme.
|
Chris@0
|
52 $this->drupalGet('admin/structure/block/demo/' . $theme);
|
Chris@0
|
53 $this->assertResponse(200);
|
Chris@0
|
54 // Confirm existence of link for "Exit block region demonstration".
|
Chris@0
|
55 $this->assertLinkByHref('admin/structure/block/list/' . $theme);
|
Chris@0
|
56 }
|
Chris@0
|
57
|
Chris@0
|
58 // Confirm access to the block demo page is denied for an invalid theme.
|
Chris@0
|
59 $this->drupalGet('admin/structure/block/demo/invalid_theme');
|
Chris@0
|
60 $this->assertResponse(403);
|
Chris@0
|
61 }
|
Chris@0
|
62
|
Chris@0
|
63 }
|