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. 10 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 511

Class

BlockTest
Tests basic block functionality.

Namespace

Drupal\Tests\block\Functional

Code

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

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