You are here

protected function ContentPreviewToggleTest::assertOrderInPage in Drupal 8

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

Asserts that blocks in a given order in the page.

Parameters

string[] $items: An ordered list of strings that should appear in the blocks.

1 call to ContentPreviewToggleTest::assertOrderInPage()
ContentPreviewToggleTest::testContentPreviewToggle in core/modules/layout_builder/tests/src/FunctionalJavascript/ContentPreviewToggleTest.php
Tests the content preview toggle.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/ContentPreviewToggleTest.php, line 146

Class

ContentPreviewToggleTest
Tests toggling of content preview.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function assertOrderInPage(array $items) {
  $session = $this
    ->getSession();
  $page = $session
    ->getPage();
  $blocks = $page
    ->findAll('css', '[data-layout-content-preview-placeholder-label]');

  // Filter will only return value if block contains expected text.
  $blocks_with_expected_text = ArrayUtils::filter($blocks, function ($block, $key) use ($items) {
    $block_text = $block
      ->getText();
    return strpos($block_text, $items[$key]) !== FALSE;
  }, ArrayUtils::ARRAY_FILTER_USE_BOTH);
  $this
    ->assertCount(count($items), $blocks_with_expected_text);
}