You are here

protected function LayoutBuilderLockTest::checkLinksAndAccess in Layout Builder Lock 8

Checks links and access.

Parameters

\Drupal\Tests\WebAssert $assert_session:

\Drupal\node\NodeInterface $node:

bool $locked:

int $code:

null $allow_section_after:

Throws

\Behat\Mink\Exception\ElementNotFoundException

\Behat\Mink\Exception\ExpectationException

1 call to LayoutBuilderLockTest::checkLinksAndAccess()
LayoutBuilderLockTest::testLock in tests/src/Functional/LayoutBuilderLockTest.php
Tests locking features on sections.

File

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

Class

LayoutBuilderLockTest
Tests Layout Builder Lock.

Namespace

Drupal\Tests\layout_builder_lock\Functional

Code

protected function checkLinksAndAccess(WebAssert $assert_session, NodeInterface $node, $locked = FALSE, $code = 200, $allow_section_after = NULL) {
  if ($code == 200) {
    $assert_session
      ->linkExists('Add block');
    $assert_session
      ->linkExists('Add section');
    $assert_session
      ->linkExists('Remove Section 1');
    $assert_session
      ->linkExists('Configure Section 1');
    $assert_session
      ->responseContains('js-layout-builder-block');
    $assert_session
      ->responseContains('js-layout-builder-region');
  }
  else {
    if ($allow_section_after) {
      $assert_session
        ->linkExists('Add section');
    }
    else {
      $assert_session
        ->linkNotExists('Add section');
    }
    $assert_session
      ->linkNotExists('Add block');
    $assert_session
      ->linkNotExists('Remove Section 1');
    $assert_session
      ->linkNotExists('Configure Section 1');
    $assert_session
      ->responseNotContains('js-layout-builder-block');
    $assert_session
      ->responseNotContains('js-layout-builder-region');
  }
  $this
    ->checkContextualLinks($assert_session, $locked);
  $this
    ->checkRouteAccess($assert_session, $node, $code, $allow_section_after);
}