You are here

public function BlockFormRoutesAccessTest::testBlockEditFormAccess in Block permissions 8

Tests the access to the block edit page.

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

$covers ::blockFormAccess

File

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

Class

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

Namespace

Drupal\Tests\block_permissions\Functional

Code

public function testBlockEditFormAccess() {
  $page_title_block_edit = $this
    ->getBlockEditFormUrl($this->pageTitleBlock
    ->id());
  $system_branding_block_edit = $this
    ->getBlockEditFormUrl($this->systemBrandingBlock
    ->id());

  // Ensure user can edit block from core only.
  $this
    ->drupalLogin($this->coreBlocksUser);
  $this
    ->drupalGet($page_title_block_edit);
  $this
    ->assertBlockFormPageHasAccess();
  $this
    ->drupalGet($system_branding_block_edit);
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Ensure user can edit block from system module only.
  $this
    ->drupalLogin($this->systemBlocksUser);
  $this
    ->drupalGet($page_title_block_edit);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalGet($system_branding_block_edit);
  $this
    ->assertBlockFormPageHasAccess();
}