You are here

public function LayoutBuilderThemeSuggestionsTest::testFieldBlockViewModeTemplates in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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');
}