protected function PreviewLinkForwardRevisionTest::setupParagraphTypeAndField in Preview Link 2.0.x
Same name and namespace in other branches
- 8 tests/src/Functional/PreviewLinkForwardRevisionTest.php \Drupal\Tests\preview_link\Functional\PreviewLinkForwardRevisionTest::setupParagraphTypeAndField()
- 2.x tests/src/Functional/PreviewLinkForwardRevisionTest.php \Drupal\Tests\preview_link\Functional\PreviewLinkForwardRevisionTest::setupParagraphTypeAndField()
Sets up paragraph type and field.
1 call to PreviewLinkForwardRevisionTest::setupParagraphTypeAndField()
- PreviewLinkForwardRevisionTest::testDraftRevisionWithParagraphField in tests/
src/ Functional/ PreviewLinkForwardRevisionTest.php - Tests draft revision with paragraph field.
File
- tests/
src/ Functional/ PreviewLinkForwardRevisionTest.php, line 134
Class
- PreviewLinkForwardRevisionTest
- Test forward revisions are loaded.
Namespace
Drupal\Tests\preview_link\FunctionalCode
protected function setupParagraphTypeAndField() : void {
// Add a paragraph type.
$paragraph_type = ParagraphsType::create([
'id' => 'section',
'label' => 'Section',
]);
$paragraph_type
->save();
// Add a text field to the paragraph type.
$storage = FieldStorageConfig::create([
'entity_type' => 'paragraph',
'type' => 'text',
'field_name' => 'section',
]);
$storage
->save();
$field = FieldConfig::create([
'entity_type' => 'paragraph',
'field_name' => 'section',
'bundle' => 'section',
'type' => 'text',
'label' => 'Section',
]);
$field
->save();
// Add a paragraphs field.
$field_storage = FieldStorageConfig::create([
'field_name' => 'paragraphs',
'entity_type' => 'node',
'type' => 'entity_reference_revisions',
'cardinality' => '-1',
'settings' => [
'target_type' => 'paragraph',
],
]);
$field_storage
->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'field_name' => 'paragraphs',
'settings' => [
'handler' => 'default:paragraph',
],
]);
$field
->save();
$view_display = EntityViewDisplay::load('node.page.default')
->setComponent('paragraphs', [
'type' => 'entity_reference_revisions_entity_view',
]);
$view_display
->save();
$view_display = EntityViewDisplay::create([
'targetEntityType' => 'paragraph',
'bundle' => 'section',
'mode' => 'default',
'status' => TRUE,
])
->setComponent('section', [
'type' => 'text_default',
]);
$view_display
->save();
}