function LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp()
- 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php, line 39
Class
- LayoutBuilderFieldBlockEntityReferenceCacheTagsTest
- Tests cache tags on entity reference field blocks in Layout Builder.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function setUp() {
parent::setUp();
// Enable page caching.
$config = $this->config('system.performance');
$config->set('cache.page.max_age', 3600);
$config->save();
// Create two content types, with one content type containing a field that
// references entities of the second content type.
$this->createContentType([
'type' => 'bundle_with_reference_field',
'name' => 'bundle_with_reference_field',
]);
$this->createContentType([
'type' => 'bundle_referenced',
'name' => 'bundle_referenced',
]);
$this->createEntityReferenceField('node', 'bundle_with_reference_field', 'field_reference', 'Reference field', 'node', 'default', [
'target_bundles' => [
'bundle_referenced',
],
]);
// Enable layout builder to the content type with the reference field, and
// add the reference field to the layout builder display.
$this->container
->get('entity_display.repository')
->getViewDisplay('node', 'bundle_with_reference_field', 'full')
->enableLayoutBuilder()
->setComponent('field_reference', [
'type' => 'entity_reference_label',
])
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.