protected function LayoutSectionTest::assertLayoutSection in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::assertLayoutSection()
Asserts the output of a layout section.
Parameters
string|array $expected_selector: A selector or list of CSS selectors to find.
string|array $expected_content: A string or list of strings to find.
string $expected_cache_contexts: A string of cache contexts to be found in the header.
string $expected_cache_tags: A string of cache tags to be found in the header.
string $expected_dynamic_cache: The expected dynamic cache header. Either 'HIT', 'MISS' or 'UNCACHEABLE'.
2 calls to LayoutSectionTest::assertLayoutSection()
- LayoutSectionTest::testLayoutSectionFormatter in core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutSectionTest.php - Tests layout_section formatter output.
- LayoutSectionTest::testLayoutSectionFormatterAccess in core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutSectionTest.php - Tests the access checking of the section formatter.
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutSectionTest.php, line 296
Class
- LayoutSectionTest
- Tests the rendering of a layout section field.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function assertLayoutSection($expected_selector, $expected_content, $expected_cache_contexts = '', $expected_cache_tags = '', $expected_dynamic_cache = 'MISS') {
$assert_session = $this
->assertSession();
// Find the given selector.
foreach ((array) $expected_selector as $selector) {
$element = $this
->cssSelect($selector);
$this
->assertNotEmpty($element);
}
// Find the given content.
foreach ((array) $expected_content as $content) {
$assert_session
->pageTextContains($content);
}
if ($expected_cache_contexts) {
$assert_session
->responseHeaderContains('X-Drupal-Cache-Contexts', $expected_cache_contexts);
}
if ($expected_cache_tags) {
$assert_session
->responseHeaderContains('X-Drupal-Cache-Tags', $expected_cache_tags);
}
$assert_session
->responseHeaderEquals('X-Drupal-Dynamic-Cache', $expected_dynamic_cache);
}