diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index 25b7942..cf17938 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -83,13 +83,16 @@ protected function setUp() { public function testBlockDemoUiPage() { $this->drupalPlaceBlock('help_block', array('region' => 'help')); $this->drupalGet('admin/structure/block'); - $this->clickLink(t('Demonstrate block regions (@theme)', array('@theme' => 'Classy'))); + $this->clickLink(t('Demonstrate block regions (@theme)', array('@theme' => 'Test Classy'))); $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', array(':title' => 'Highlighted')); $this->assertTrue(!empty($elements), 'Block demo regions are shown.'); \Drupal::service('theme_handler')->install(array('test_theme')); $this->drupalGet('admin/structure/block/demo/test_theme'); $this->assertEscaped('Test theme'); + + $this->drupalGet('admin/structure/block/demo/classy'); + $this->assertResponse(403, 'Hidden themes cannot are not supported by the block demo screen'); } /** @@ -136,6 +139,20 @@ function testBlockAdminUiPage() { $this->drupalGet('admin/structure/block'); $element = $this->xpath('//tr[contains(@class, :class)]', [':class' => 'region-title-header']); $this->assertTrue(!empty($element)); + + // Ensure hidden themes do not appear in the UI. Enable another non base + // theme and place the local tasks block. + $this->assertTrue(\Drupal::service('theme_handler')->themeExists('classy'), 'The classy base theme is enabled'); + $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']); + \Drupal::service('theme_installer')->install(['test_theme']); + $this->drupalGet('admin/structure/block'); + $theme_handler = \Drupal::service('theme_handler'); + $this->assertLink($theme_handler->getName('test_classy')); + $this->assertLink($theme_handler->getName('test_theme')); + $this->assertNoLink($theme_handler->getName('classy')); + + $this->drupalGet('admin/structure/block/list/classy'); + $this->assertResponse(403, 'Placing blocks through UI is not possible for the base theme classy.'); } /** @@ -145,7 +162,7 @@ public function testCandidateBlockList() { $arguments = array( ':title' => 'Display message', ':category' => 'Block test', - ':href' => 'admin/structure/block/add/test_block_instantiation/classy', + ':href' => 'admin/structure/block/add/test_block_instantiation/test_classy', ); $pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]'; @@ -171,7 +188,7 @@ public function testCandidateBlockList() { public function testContextAwareUnsatisfiedBlocks() { $arguments = array( ':category' => 'Block test', - ':href' => 'admin/structure/block/add/test_context_aware_unsatisfied/classy', + ':href' => 'admin/structure/block/add/test_context_aware_unsatisfied/test_classy', ':text' => 'Test context-aware unsatisfied block', ); @@ -193,7 +210,7 @@ public function testContextAwareBlocks() { $this->assertNoText('Test context-aware block'); $this->assertNoRaw($expected_text); - $block_url = 'admin/structure/block/add/test_context_aware/classy'; + $block_url = 'admin/structure/block/add/test_context_aware/test_classy'; $arguments = array( ':title' => 'Test context-aware block', ':category' => 'Block test', @@ -231,7 +248,7 @@ public function testContextAwareBlocks() { * Tests that the BlockForm populates machine name correctly. */ public function testMachineNameSuggestion() { - $url = 'admin/structure/block/add/test_block_instantiation/classy'; + $url = 'admin/structure/block/add/test_block_instantiation/test_classy'; $this->drupalGet($url); $this->assertFieldByName('id', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.'); $this->drupalPostForm($url, array(), 'Save block'); @@ -253,16 +270,16 @@ public function testBlockPlacementIndicator() { // Select the 'Powered by Drupal' block to be placed. $block = array(); $block['id'] = strtolower($this->randomMachineName()); - $block['theme'] = 'classy'; + $block['theme'] = 'test_classy'; $block['region'] = 'content'; // After adding a block, it will indicate which block was just added. $this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, t('Save block')); - $this->assertUrl('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id'])); + $this->assertUrl('admin/structure/block/list/test_classy?block-placement=' . Html::getClass($block['id'])); // Resaving the block page will remove the block indicator. $this->drupalPostForm(NULL, array(), t('Save blocks')); - $this->assertUrl('admin/structure/block/list/classy'); + $this->assertUrl('admin/structure/block/list/test_classy'); } } diff --git a/core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml b/core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml index be7e06c..32f8e95 100644 --- a/core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml +++ b/core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml @@ -13,5 +13,5 @@ dependencies: module: - block_test theme: - - classy + - test_classy visibility: { } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index e669a72..e176e56 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -186,16 +186,14 @@ public function testsBlockContentAddTypes() { // Install all themes. \Drupal::service('theme_handler')->install(array('bartik', 'seven')); - $themes = array('bartik', 'seven', 'classy'); $theme_settings = $this->config('system.theme'); - foreach ($themes as $default_theme) { + foreach (['bartik', 'seven', 'test_classy'] as $default_theme) { // Change the default theme. $theme_settings->set('default', $default_theme)->save(); \Drupal::service('router.builder')->rebuild(); // For each installed theme, go to its block page and test the redirects. - $themes = array('bartik', 'classy', 'seven'); - foreach ($themes as $theme) { + foreach (['bartik', 'test_classy', 'seven'] as $theme) { // Test that adding a block from the 'place blocks' form sends you to the // block configure form. $path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme"; diff --git a/core/modules/block_content/tests/modules/block_content_test/config/install/block.block.foobargorilla.yml b/core/modules/block_content/tests/modules/block_content_test/config/install/block.block.foobargorilla.yml index 42858f7..49fbc53 100644 --- a/core/modules/block_content/tests/modules/block_content_test/config/install/block.block.foobargorilla.yml +++ b/core/modules/block_content/tests/modules/block_content_test/config/install/block.block.foobargorilla.yml @@ -4,9 +4,9 @@ dependencies: module: - block_content theme: - - classy + - test_classy id: foobargorilla -theme: classy +theme: test_classy region: content weight: null provider: null