diff --git a/core/modules/block/src/Tests/BlockDemoTest.php b/core/modules/block/src/Tests/BlockDemoTest.php index afda648..a1e9d09 100644 --- a/core/modules/block/src/Tests/BlockDemoTest.php +++ b/core/modules/block/src/Tests/BlockDemoTest.php @@ -31,36 +31,37 @@ public function testBlockDemo() { $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); $this->drupalLogin($admin_user); - // Install default theme and confirm we have access to the demo page for it. + // Confirm we have access to the block demo page for the default theme. $config = \Drupal::config('system.theme'); $default_theme = $config->get('default'); - \Drupal::service('theme_handler')->install(array($default_theme)); - $edit['admin_theme'] = $default_theme; - $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/demo/' . $default_theme); $this->assertResponse(200); $this->assertLinkByHref('admin/structure/block'); $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme); - // Install bartik theme and confirm we have access to the demo page for it. - \Drupal::service('theme_handler')->install(array('bartik')); - $edit['admin_theme'] = 'bartik'; - $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); - $this->drupalGet('admin/structure/block/demo/bartik'); - $this->assertResponse(200); - $this->assertLinkByHref('admin/structure/block/list/bartik'); + // All available themes in core. + $available_themes = array( + 'bartik', + 'classy', + 'seven', + 'stark', + ); - // Install seven theme and confirm we have access to the demo page for it. - \Drupal::service('theme_handler')->install(array('seven')); - $edit['admin_theme'] = 'seven'; - $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); - $this->drupalGet('admin/structure/block/demo/seven'); - $this->assertResponse(200); - $this->assertLinkByHref('admin/structure/block/list/seven'); + // All available themes minute minus the default theme. + $themes = array_diff($available_themes, array($default_theme)); - // Make sure there is no access for an invalid theme. + foreach ($themes as $theme) { + // Install theme. + \Drupal::service('theme_handler')->install(array($theme)); + // Confirm access to the block demo page for the theme. + $this->drupalGet('admin/structure/block/demo/' . $theme); + $this->assertResponse(200); + // Confirm existence of link for "Exit block region demonstration". + $this->assertLinkByHref('admin/structure/block/list/' . $theme); + } + + // Confirm access to the block demo page is denied for an invalid theme. $this->drupalGet('admin/structure/block/demo/invalid_theme'); $this->assertResponse(403); - } }