You are here

public function BlockTest::testBlockAccess in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testBlockAccess()
  2. 9 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 548

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
    ->assertSession()
    ->pageTextNotContains('Hello test world');
  \Drupal::state()
    ->set('test_block_access', TRUE);
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->pageTextContains('Hello test world');
}