You are here

protected function BlocacheBrowserTestBase::setUp in Blocache (Block Cache Control) 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/BlocacheBrowserTestBase.php, line 43

Class

BlocacheBrowserTestBase
Provides setup and helper methods for block module tests.

Namespace

Drupal\Tests\blocache\Functional

Code

protected function setUp() {
  parent::setUp();

  // Use the test page as the front page.
  $this
    ->config('system.site')
    ->set('page.front', '/test-page')
    ->save();

  // Create and log in an administrative user having access to the Full HTML
  // text format.
  $this->adminUser = $this
    ->drupalCreateUser([
    'administer blocks',
    'access administration pages',
    'administer block cache',
  ]);
  $this
    ->drupalLogin($this->adminUser);

  // Define the existing regions.
  $this->regions = [
    'header',
    'sidebar_first',
    'content',
    'sidebar_second',
    'footer',
  ];
  $block_storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('block');
  $blocks = $block_storage
    ->loadByProperties([
    'theme' => $this
      ->config('system.theme')
      ->get('default'),
  ]);
  foreach ($blocks as $block) {
    $block
      ->delete();
  }
}