function BlockPlaceTest::testPlacingBlocksUnprivileged

Tests placing blocks as an unprivileged user.

File

core/modules/block_place/tests/src/Functional/BlockPlaceTest.php, line 67

Class

BlockPlaceTest
Tests the placing a block.

Namespace

Drupal\Tests\block_place\Functional

Code

public function testPlacingBlocksUnprivileged() {
    // Create a user who cannot administer blocks.
    $this->drupalLogin($this->drupalCreateUser([
        'access administration pages',
        'access toolbar',
        'view the administration theme',
    ]));
    $this->drupalGet(Url::fromRoute('<front>'));
    $links = $this->xpath('//a[text()=:label]', [
        ':label' => 'Place block',
    ]);
    $this->assertEmpty($links);
    $this->drupalGet(Url::fromRoute('block.admin_library', [
        'theme' => 'classy',
    ]));
    $this->assertSession()
        ->statusCodeEquals(403);
}

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