function LayoutSectionTest::testLayoutSectionFormatterAccess
Same name in other branches
- 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::testLayoutSectionFormatterAccess()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::testLayoutSectionFormatterAccess()
- 11.x core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::testLayoutSectionFormatterAccess()
Tests the access checking of the section formatter.
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutSectionTest.php, line 186
Class
- LayoutSectionTest
- Tests the rendering of a layout section field.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testLayoutSectionFormatterAccess() {
$node = $this->createSectionNode([
[
'section' => new Section('layout_onecol', [], [
'baz' => new SectionComponent('baz', 'content', [
'id' => 'test_access',
]),
]),
],
]);
// Restrict access to the block.
$this->container
->get('state')
->set('test_block_access', FALSE);
$this->drupalGet($node->toUrl('canonical'));
$this->assertLayoutSection('.layout--onecol', NULL, '', '', 'UNCACHEABLE');
// Ensure the block was not rendered.
$this->assertSession()
->pageTextNotContains('Hello test world');
// Grant access to the block, and ensure it was rendered.
$this->container
->get('state')
->set('test_block_access', TRUE);
$this->drupalGet($node->toUrl('canonical'));
$this->assertLayoutSection('.layout--onecol', 'Hello test world', '', '', 'UNCACHEABLE');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.