You are here

public function BlockFormRoutesAccessTest::testBlockDeleteFormAccess in Block permissions 8

Tests the access to the block delete page.

Path to test: "/admin/structure/block/manage/{block}/delete".

$covers ::blockFormAccess

File

tests/src/Functional/BlockFormRoutesAccessTest.php, line 137

Class

BlockFormRoutesAccessTest
Tests Block permissions access control handler for block configuration pages.

Namespace

Drupal\Tests\block_permissions\Functional

Code

public function testBlockDeleteFormAccess() {
  $page_title_block_delete = $this
    ->getBlockDeleteFormUrl($this->pageTitleBlock
    ->id());
  $system_branding_block_delete = $this
    ->getBlockDeleteFormUrl($this->systemBrandingBlock
    ->id());

  // Ensure user can delete block from core only.
  $this
    ->drupalLogin($this->coreBlocksUser);
  $this
    ->drupalGet($page_title_block_delete);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains($this
    ->getBlockDeleteFormTitle($this->pageTitleBlock
    ->label()));
  $this
    ->drupalGet($system_branding_block_delete);
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Ensure user can delete block from system module only.
  $this
    ->drupalLogin($this->systemBlocksUser);
  $this
    ->drupalGet($page_title_block_delete);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalGet($system_branding_block_delete);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains($this
    ->getBlockDeleteFormTitle($this->systemBrandingBlock
    ->label()));
}