function LayoutBuilderDefaultValuesTest::assertNodeWithValues
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderDefaultValuesTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderDefaultValuesTest::assertNodeWithValues()
- 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderDefaultValuesTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderDefaultValuesTest::assertNodeWithValues()
Test for expected text on node 1.
1 call to LayoutBuilderDefaultValuesTest::assertNodeWithValues()
- 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 120
Class
- LayoutBuilderDefaultValuesTest
- Tests rendering default field values in Layout Builder.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function assertNodeWithValues() {
$this->drupalGet('node/1');
$assert_session = $this->assertSession();
// String field with no default should render a value.
$assert_session->pageTextContains('field_string_no_default');
$assert_session->pageTextContains('No default, no problem.');
// String field with default should render non-default value.
$assert_session->pageTextContains('field_string_with_default');
$assert_session->pageTextNotContains('This is my default value');
$assert_session->pageTextContains('It is ok to be different');
// String field with callback should render non-default value.
$assert_session->pageTextContains('field_string_with_callback');
$assert_session->pageTextNotContains('This is from my default value callback');
$assert_session->pageTextContains('Not from a callback');
// String field with "late" default should render non-default value.
$assert_session->pageTextContains('field_string_late_default');
$assert_session->pageTextNotContains('Too late!');
$assert_session->pageTextContains('I am way ahead of you');
// Image field with storage default should render non-default value.
$assert_session->pageTextContains('field_image_storage_default');
$assert_session->responseNotContains('My storage default alt text');
$assert_session->responseNotContains('test-file-1');
$assert_session->responseContains('My third alt text');
$assert_session->responseContains('test-file-3');
// Image field with instance default should render non-default value.
$assert_session->pageTextContains('field_image_instance_default');
$assert_session->responseNotContains('My instance default alt text');
$assert_session->responseNotContains('test-file-1');
$assert_session->responseContains('My fourth alt text');
$assert_session->responseContains('test-file-4');
// Image field with both storage and instance defaults should render
// non-default value.
$assert_session->pageTextContains('field_image_both_defaults');
$assert_session->responseNotContains('My storage default alt text');
$assert_session->responseNotContains('My instance default alt text');
$assert_session->responseNotContains('test-file-1');
$assert_session->responseNotContains('test-file-2');
$assert_session->responseContains('My fifth alt text');
$assert_session->responseContains('test-file-5');
// Image field with no default should render a value.
$assert_session->pageTextContains('field_image_no_default');
$assert_session->responseContains('My sixth alt text');
$assert_session->responseContains('test-file-6');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.