You are here

protected function LayoutBuilderLockTest::checkRouteAccess in Layout Builder Lock 8

Checks access to routes related to layout builder.

Parameters

\Drupal\Tests\WebAssert $assert_session:

\Drupal\node\NodeInterface $node:

int $code:

null $section_after:

Throws

\Behat\Mink\Exception\ExpectationException

1 call to LayoutBuilderLockTest::checkRouteAccess()
LayoutBuilderLockTest::checkLinksAndAccess in tests/src/Functional/LayoutBuilderLockTest.php
Checks links and access.

File

tests/src/Functional/LayoutBuilderLockTest.php, line 468

Class

LayoutBuilderLockTest
Tests Layout Builder Lock.

Namespace

Drupal\Tests\layout_builder_lock\Functional

Code

protected function checkRouteAccess(WebAssert $assert_session, NodeInterface $node, $code = 200, $section_after = NULL) {
  $paths = [
    'layout_builder/configure/section/overrides/node.' . $node
      ->id() . '/0',
    'layout_builder/remove/section/overrides/node.' . $node
      ->id() . '/0',
    'layout_builder/choose/section/overrides/node.' . $node
      ->id() . '/0',
    'layout_builder/choose/section/overrides/node.' . $node
      ->id() . '/1',
    'layout_builder/choose/block/overrides/node.' . $node
      ->id() . '/0/content',
    'layout_builder/update/block/overrides/node.' . $node
      ->id() . '/0/content/' . $this->body_field_block_uuid,
    'layout_builder/move/block/overrides/node.' . $node
      ->id() . '/0/content/' . $this->body_field_block_uuid,
    'layout_builder/remove/block/overrides/node.' . $node
      ->id() . '/0/content/' . $this->body_field_block_uuid,
  ];
  foreach ($paths as $path) {
    $this
      ->drupalGet($path);
    if ($section_after && $path == 'layout_builder/choose/section/overrides/node.' . $node
      ->id() . '/1') {
      $assert_session
        ->statusCodeEquals(200);
    }
    else {
      $assert_session
        ->statusCodeEquals($code);
    }
  }
}