You are here

protected function BlockCacheTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Functional/BlockCacheTest.php \Drupal\Tests\block\Functional\BlockCacheTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/block/tests/src/Functional/BlockCacheTest.php, line 55

Class

BlockCacheTest
Tests block caching.

Namespace

Drupal\Tests\block\Functional

Code

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

  // Create an admin user, log in and enable test blocks.
  $this->adminUser = $this
    ->drupalCreateUser([
    'administer blocks',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($this->adminUser);

  // Create additional users to test caching modes.
  $this->normalUser = $this
    ->drupalCreateUser();
  $this->normalUserAlt = $this
    ->drupalCreateUser();

  // Sync the roles, since drupalCreateUser() creates separate roles for
  // the same permission sets.
  $this->normalUserAlt->roles = $this->normalUser
    ->getRoles();
  $this->normalUserAlt
    ->save();

  // Enable our test block.
  $this->block = $this
    ->drupalPlaceBlock('test_cache');
}