function LayoutBuilderDisableInteractionsTest::setUp

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::setUp()
  2. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::setUp()
  3. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php, line 52

Class

LayoutBuilderDisableInteractionsTest
Tests the Layout Builder disables interactions of rendered blocks.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function setUp() : void {
    parent::setUp();
    $this->createContentType([
        'type' => 'bundle_with_section_field',
    ]);
    $this->createNode([
        'type' => 'bundle_with_section_field',
        'title' => 'The first node title',
        'body' => [
            [
                'value' => 'Node body',
            ],
        ],
    ]);
    $bundle = BlockContentType::create([
        'id' => 'basic',
        'label' => 'Basic block',
        'revision' => 1,
    ]);
    $bundle->save();
    block_content_add_body_field($bundle->id());
    BlockContent::create([
        'type' => 'basic',
        'info' => 'Block with link',
        'body' => [
            // Create a link that should be disabled in Layout Builder preview.
'value' => '<a id="link-that-should-be-disabled" href="/search/node">Take me away</a>',
            'format' => 'full_html',
        ],
    ])->save();
    BlockContent::create([
        'type' => 'basic',
        'info' => 'Block with iframe',
        'body' => [
            // Add iframe that should be non-interactive in Layout Builder preview.
'value' => '<iframe id="iframe-that-should-be-disabled" width="1" height="1" src="https://www.youtube.com/embed/gODZzSOelss" frameborder="0"></iframe>',
            'format' => 'full_html',
        ],
    ])->save();
}

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