function LayoutBuilderDefaultValuesTest::assertNodeWithDefaultValues

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

Test for expected text on node 2.

1 call to LayoutBuilderDefaultValuesTest::assertNodeWithDefaultValues()
LayoutBuilderDefaultValuesTest::testDefaultValues in core/modules/layout_builder/tests/src/Functional/LayoutBuilderDefaultValuesTest.php
Tests display of default field values.

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderDefaultValuesTest.php, line 141

Class

LayoutBuilderDefaultValuesTest
Tests rendering default field values in Layout Builder.

Namespace

Drupal\Tests\layout_builder\Functional

Code

protected function assertNodeWithDefaultValues() {
    $this->drupalGet('node/2');
    $assert_session = $this->assertSession();
    // String field with no default should not render.
    $assert_session->pageTextNotContains('field_string_no_default');
    // String with default value should render with default value.
    $assert_session->pageTextContains('field_string');
    $assert_session->pageTextContains('This is my default value');
    // String field with callback should render value from callback.
    $assert_session->pageTextContains('field_string_with_callback');
    $assert_session->pageTextContains('This is from my default value callback');
    // String field with "late" default should not render.
    $assert_session->pageTextNotContains('field_string_late_default');
    $assert_session->pageTextNotContains('Too late!');
    // Image field with default should render default value.
    $assert_session->pageTextContains('field_image_with_default');
    $assert_session->responseContains('My default alt text');
    $assert_session->responseContains('test-file-1');
    // Image field with no default should not render.
    $assert_session->pageTextNotContains('field_image_no_default');
}

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