public function BlockUiTest::testRouteProtection in Drupal 8
Same name and namespace in other branches
- 9 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testRouteProtection()
Tests that the enable/disable routes are protected from CSRF.
File
- core/
modules/ block/ tests/ src/ Functional/ BlockUiTest.php, line 374
Class
- BlockUiTest
- Tests that the block configuration UI exists and stores data correctly.
Namespace
Drupal\Tests\block\FunctionalCode
public function testRouteProtection() {
// Get the first block generated in our setUp method.
/** @var \Drupal\block\BlockInterface $block */
$block = reset($this->blocks);
// Ensure that the enable and disable routes are protected.
$this
->drupalGet('admin/structure/block/manage/' . $block
->id() . '/disable');
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalGet('admin/structure/block/manage/' . $block
->id() . '/enable');
$this
->assertSession()
->statusCodeEquals(403);
}