You are here

protected function MoveBlockFormTest::assertRegionBlocksOrder in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\MoveBlockFormTest::assertRegionBlocksOrder()

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.

2 calls to MoveBlockFormTest::assertRegionBlocksOrder()
MoveBlockFormTest::setUp in core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php
MoveBlockFormTest::testMoveBlock in core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php
Tests moving a block.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php, line 209

Class

MoveBlockFormTest
Tests moving blocks via the form.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function assertRegionBlocksOrder($section_delta, $region, array $expected_block_selectors) {
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();
  $assert_session
    ->assertWaitOnAjaxRequest();
  $assert_session
    ->assertNoElementAfterWait('css', '#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'));
  }
}