function LayoutBuilderThemeSuggestionsTest::testFieldBlockViewModeTemplates

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderThemeSuggestionsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderThemeSuggestionsTest::testFieldBlockViewModeTemplates()
  2. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderThemeSuggestionsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderThemeSuggestionsTest::testFieldBlockViewModeTemplates()
  3. 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderThemeSuggestionsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderThemeSuggestionsTest::testFieldBlockViewModeTemplates()

Tests that of view mode specific field templates are suggested.

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderThemeSuggestionsTest.php, line 72

Class

LayoutBuilderThemeSuggestionsTest
Tests template suggestions.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testFieldBlockViewModeTemplates() {
    $assert_session = $this->assertSession();
    $this->drupalGet('node/1');
    // Confirm that content is displayed by layout builder.
    $assert_session->elementExists('css', '.block-layout-builder');
    // Text that only appears in the view mode specific template.
    $assert_session->pageTextContains('I am a field template for a specific view mode!');
    // The content of the body field should not be visible because it is
    // displayed via a template that does not render it.
    $assert_session->pageTextNotContains('This is content that the template should not render');
}

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