function BlockCacheTest::setUp

Same name in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockCacheTest.php \Drupal\Tests\block\Functional\BlockCacheTest::setUp()
  2. 8.9.x core/modules/block/tests/src/Functional/BlockCacheTest.php \Drupal\Tests\block\Functional\BlockCacheTest::setUp()
  3. 10 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 58

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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.