You are here

protected function MoveBlockHelperTrait::assertRegionBlocksOrder in Layout Builder Restrictions 8.2

Asserts that blocks are in the correct order for a region.

Parameters

int $section_delta: The section delta.

string $region: The region.

array $expected_block_selectors: The block selectors.

6 calls to MoveBlockHelperTrait::assertRegionBlocksOrder()
MoveBlockBlacklistTest::testMovePluginBlock in modules/layout_builder_restrictions_by_region/tests/src/FunctionalJavascript/MoveBlockBlacklistTest.php
Tests moving a plugin block.
MoveBlockCategoryRestrictionTest::testMovePluginBlock in modules/layout_builder_restrictions_by_region/tests/src/FunctionalJavascript/MoveBlockCategoryRestrictionTest.php
Tests moving a plugin block.
MoveBlockRestrictionTest::testLayoutLibraryMovePluginBlock in tests/src/FunctionalJavascript/MoveBlockRestrictionTest.php
Move a plugin block in the Layout Library.
MoveBlockRestrictionTest::testMoveContentBlock in tests/src/FunctionalJavascript/MoveBlockRestrictionTest.php
Tests moving a content block.
MoveBlockRestrictionTest::testMovePluginBlock in tests/src/FunctionalJavascript/MoveBlockRestrictionTest.php
Tests moving a plugin block.

... See full list

File

tests/src/Traits/MoveBlockHelperTrait.php, line 95

Class

MoveBlockHelperTrait
General-purpose methods for moving blocks in Layout Builder.

Namespace

Drupal\Tests\layout_builder_restrictions\Traits

Code

protected function assertRegionBlocksOrder($section_delta, $region, array $expected_block_selectors) {
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();
  $assert_session
    ->assertWaitOnAjaxRequest();
  $this
    ->waitForNoElement('#drupal-off-canvas');
  $region_selector = "[data-layout-delta=\"{$section_delta}\"] [data-region=\"{$region}\"]";

  // Get all blocks currently in the region.
  $blocks = $page
    ->findAll('css', "{$region_selector} [data-layout-block-uuid]");
  $this
    ->assertCount(count($expected_block_selectors), $blocks);

  /** @var \Behat\Mink\Element\NodeElement $block */
  foreach ($blocks as $block) {
    $block_selector = array_shift($expected_block_selectors);
    $assert_session
      ->elementsCount('css', "{$region_selector} {$block_selector}", 1);
    $expected_block = $page
      ->find('css', "{$region_selector} {$block_selector}");
    $this
      ->assertSame($expected_block
      ->getAttribute('data-layout-block-uuid'), $block
      ->getAttribute('data-layout-block-uuid'));
  }
}