3 namespace Drupal\Tests\block\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests the block demo page with admin themes.
12 class BlockDemoTest extends BrowserTestBase {
19 public static $modules = ['block'];
22 * Check for the accessibility of the admin block demo page.
24 public function testBlockDemo() {
25 // Create administrative user.
26 $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
27 $this->drupalLogin($admin_user);
29 // Confirm we have access to the block demo page for the default theme.
30 $config = $this->container->get('config.factory')->get('system.theme');
31 $default_theme = $config->get('default');
32 $this->drupalGet('admin/structure/block/demo/' . $default_theme);
33 $this->assertResponse(200);
34 $this->assertLinkByHref('admin/structure/block');
35 $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme);
37 // All available themes in core.
45 // All available themes minute minus the default theme.
46 $themes = array_diff($available_themes, [$default_theme]);
48 foreach ($themes as $theme) {
50 $this->container->get('theme_handler')->install([$theme]);
51 // Confirm access to the block demo page for the theme.
52 $this->drupalGet('admin/structure/block/demo/' . $theme);
53 $this->assertResponse(200);
54 // Confirm existence of link for "Exit block region demonstration".
55 $this->assertLinkByHref('admin/structure/block/list/' . $theme);
58 // Confirm access to the block demo page is denied for an invalid theme.
59 $this->drupalGet('admin/structure/block/demo/invalid_theme');
60 $this->assertResponse(403);