annotate core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
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 that a newly installed theme does not inherit blocks to its hidden
Chris@0 9 * regions.
Chris@0 10 *
Chris@0 11 * @group block
Chris@0 12 */
Chris@0 13 class BlockHiddenRegionTest extends BrowserTestBase {
Chris@0 14
Chris@0 15 /**
Chris@0 16 * An administrative user to configure the test environment.
Chris@0 17 */
Chris@0 18 protected $adminUser;
Chris@0 19
Chris@0 20 /**
Chris@0 21 * Modules to install.
Chris@0 22 *
Chris@0 23 * @var array
Chris@0 24 */
Chris@0 25 public static $modules = ['block', 'block_test', 'search'];
Chris@0 26
Chris@0 27 protected function setUp() {
Chris@0 28 parent::setUp();
Chris@0 29
Chris@0 30 // Create administrative user.
Chris@0 31 $this->adminUser = $this->drupalCreateUser([
Chris@0 32 'administer blocks',
Chris@0 33 'administer themes',
Chris@0 34 'search content',
Chris@0 35 ]
Chris@0 36 );
Chris@0 37
Chris@0 38 $this->drupalLogin($this->adminUser);
Chris@0 39 $this->drupalPlaceBlock('search_form_block');
Chris@0 40 $this->drupalPlaceBlock('local_tasks_block');
Chris@0 41 }
Chris@0 42
Chris@0 43 /**
Chris@0 44 * Tests that hidden regions do not inherit blocks when a theme is installed.
Chris@0 45 */
Chris@0 46 public function testBlockNotInHiddenRegion() {
Chris@0 47
Chris@0 48 // Ensure that the search form block is displayed.
Chris@0 49 $this->drupalGet('');
Chris@0 50 $this->assertText('Search', 'Block was displayed on the front page.');
Chris@0 51
Chris@0 52 // Install "block_test_theme" and set it as the default theme.
Chris@0 53 $theme = 'block_test_theme';
Chris@0 54 // We need to install a non-hidden theme so that there is more than one
Chris@0 55 // local task.
Chris@0 56 \Drupal::service('theme_handler')->install([$theme, 'stark']);
Chris@0 57 $this->config('system.theme')
Chris@0 58 ->set('default', $theme)
Chris@0 59 ->save();
Chris@0 60 // Installing a theme will cause the kernel terminate event to rebuild the
Chris@0 61 // router. Simulate that here.
Chris@0 62 \Drupal::service('router.builder')->rebuildIfNeeded();
Chris@0 63
Chris@0 64 // Ensure that "block_test_theme" is set as the default theme.
Chris@0 65 $this->drupalGet('admin/structure/block');
Chris@0 66 $this->assertText('Block test theme(' . t('active tab') . ')', 'Default local task on blocks admin page is the block test theme.');
Chris@0 67
Chris@0 68 // Ensure that the search form block is displayed.
Chris@0 69 $this->drupalGet('');
Chris@0 70 $this->assertText('Search', 'Block was displayed on the front page.');
Chris@0 71 }
Chris@0 72
Chris@0 73 }