protected function LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp()
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::setUp()
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php, line 38
Class
- LayoutBuilderFieldBlockEntityReferenceCacheTagsTest
- Tests cache tags on entity reference field blocks in Layout Builder.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function setUp() : void {
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();
}