protected function ContentTranslationWorkflowsTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationWorkflowsTest::setUp()
- 9 core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationWorkflowsTest::setUp()
File
- core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationWorkflowsTest.php, line 72
Class
- ContentTranslationWorkflowsTest
- Tests the content translation workflows for the test entity.
Namespace
Drupal\Tests\content_translation\FunctionalCode
protected function setUp() : void {
parent::setUp();
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_reference',
'type' => 'entity_reference',
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
'settings' => [
'target_type' => $this->entityTypeId,
],
]);
$field_storage
->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $this->entityTypeId,
'label' => 'Reference',
'translatable' => FALSE,
])
->save();
$this->container
->get('entity_display.repository')
->getViewDisplay($this->entityTypeId, $this->entityTypeId, 'default')
->setComponent('field_reference', [
'type' => 'entity_reference_entity_view',
])
->save();
$this
->setupEntity();
// Create a second entity that references the first to test how the
// translation can be viewed through an entity reference field.
$this->referencingEntity = EntityTestMulRevPub::create([
'name' => 'referencing',
'field_reference' => $this->entity
->id(),
]);
$this->referencingEntity
->addTranslation($this->langcodes[2], $this->referencingEntity
->toArray());
$this->referencingEntity
->save();
}