protected function EntityReferenceRevisionsCompositeTranslatableFieldTest::setUp in Entity Reference Revisions 8
Overrides EntityKernelTestBase::setUp
File
- tests/
src/ Kernel/ EntityReferenceRevisionsCompositeTranslatableFieldTest.php, line 57
Class
- EntityReferenceRevisionsCompositeTranslatableFieldTest
- Tests entity_reference_revisions composites with a translatable field.
Namespace
Drupal\Tests\entity_reference_revisions\KernelCode
protected function setUp() {
parent::setUp();
ConfigurableLanguage::createFromLangcode('de')
->save();
ConfigurableLanguage::createFromLangcode('fr')
->save();
$this
->installEntitySchema('entity_test_composite');
$this
->installSchema('node', [
'node_access',
]);
// Create article content type.
NodeType::create([
'type' => 'article',
'name' => 'Article',
])
->save();
// Create the reference to the composite entity test.
$field_storage = FieldStorageConfig::create(array(
'field_name' => 'composite_reference',
'entity_type' => 'node',
'type' => 'entity_reference_revisions',
'settings' => array(
'target_type' => 'entity_test_composite',
),
));
$field_storage
->save();
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'article',
'translatable' => TRUE,
));
$field
->save();
// Inject database connection and entity type manager for the tests.
$this->database = \Drupal::database();
$this->entityTypeManager = \Drupal::entityTypeManager();
// @todo content_translation should not be needed for a storage test, but
// \Drupal\Core\Entity\ContentEntityBase::isTranslatable() only returns
// TRUE if the bundle is explicitly translatable.
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
\Drupal::service('content_translation.manager')
->setEnabled('entity_test_composite', 'entity_test_composite', TRUE);
\Drupal::service('content_translation.manager')
->setBundleTranslationSettings('node', 'article', [
'untranslatable_fields_hide' => TRUE,
]);
\Drupal::service('entity_type.bundle.info')
->clearCachedBundles();
}