function ContentPreviewToggleTest::assertOrderInPage

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/ContentPreviewToggleTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContentPreviewToggleTest::assertOrderInPage()
  2. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/ContentPreviewToggleTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContentPreviewToggleTest::assertOrderInPage()
  3. 11.x 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.

@internal

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 152

Class

ContentPreviewToggleTest
Tests toggling of content preview.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function assertOrderInPage(array $items) : void {
    $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 = array_filter($blocks, function ($block, $key) use ($items) {
        $block_text = $block->getText();
        return str_contains($block_text, $items[$key]);
    }, ARRAY_FILTER_USE_BOTH);
    $this->assertSameSize($items, $blocks_with_expected_text);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.