function ClearCacheBlockTest::testCacheClearBlock

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Functional/Block/ClearCacheBlockTest.php \Drupal\Tests\system\Functional\Block\ClearCacheBlockTest::testCacheClearBlock()

Tests block behavior and access based on permissions.

File

core/modules/system/tests/src/Functional/Block/ClearCacheBlockTest.php, line 56

Class

ClearCacheBlockTest
Tests clear cache block behavior.

Namespace

Drupal\Tests\system\Functional\Block

Code

public function testCacheClearBlock() : void {
  $this->drupalGet('<front>');
  $this->assertSession()
    ->pageTextContains('Clear cache block');
  $page = $this->getSession()
    ->getPage();
  $page->pressButton('Clear all caches');
  $this->assertSession()
    ->statusMessageContains('Caches cleared.');
  // Confirm that access is not allowed for non-authorized users.
  $this->drupalLogout();
  $this->drupalGet('<front>');
  $this->assertSession()
    ->pageTextNotContains('Clear cache block');
}

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