function BlockTest::testBlockAccess

Same name in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testBlockAccess()
  2. 8.9.x core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testBlockAccess()
  3. 11.x core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testBlockAccess()

Tests the block access.

File

core/modules/block/tests/src/Functional/BlockTest.php, line 574

Class

BlockTest
Tests basic block functionality.

Namespace

Drupal\Tests\block\Functional

Code

public function testBlockAccess() : void {
    $this->drupalPlaceBlock('test_access', [
        'region' => 'help',
    ]);
    $this->drupalGet('<front>');
    $this->assertSession()
        ->pageTextNotContains('Hello test world');
    \Drupal::state()->set('test_block_access', TRUE);
    $this->drupalGet('<front>');
    $this->assertSession()
        ->pageTextContains('Hello test world');
}

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