From f6df60e1b8504f60212c56b2f2341a534cba03d1 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Thu, 29 Jun 2017 15:56:18 +0100 Subject: [PATCH] Issue #2352791 by prics, sam0971, naveenvalecha, Ashish.Dalvi, dstotijn, ZeiP, Mile23, tim.plunkett: Add test coverage for admin/structure/block/demo --- .../tests/src/Functional/BlockDemoTest.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 core/modules/block/tests/src/Functional/BlockDemoTest.php diff --git a/core/modules/block/tests/src/Functional/BlockDemoTest.php b/core/modules/block/tests/src/Functional/BlockDemoTest.php new file mode 100644 index 00000000000..884b587a11a --- /dev/null +++ b/core/modules/block/tests/src/Functional/BlockDemoTest.php @@ -0,0 +1,63 @@ +drupalCreateUser(['administer blocks', 'administer themes']); + $this->drupalLogin($admin_user); + + // Confirm we have access to the block demo page for the default theme. + $config = $this->container->get('config.factory')->get('system.theme'); + $default_theme = $config->get('default'); + $this->drupalGet('admin/structure/block/demo/' . $default_theme); + $this->assertResponse(200); + $this->assertLinkByHref('admin/structure/block'); + $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme); + + // All available themes in core. + $available_themes = [ + 'bartik', + 'classy', + 'seven', + 'stark', + ]; + + // All available themes minute minus the default theme. + $themes = array_diff($available_themes, [$default_theme]); + + foreach ($themes as $theme) { + // Install theme. + $this->container->get('theme_handler')->install([$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); + } + +}