function ContentTranslationFieldSyncRevisionTest::setUp
Same name in other branches
- 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::setUp()
- 8.9.x core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::setUp()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::setUp()
Overrides EntityKernelTestBase::setUp
File
-
core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php, line 63
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function setUp() : void {
parent::setUp();
$entity_type_id = 'entity_test_mulrev';
$this->installEntitySchema($entity_type_id);
$this->installEntitySchema('file');
$this->installSchema('file', [
'file_usage',
]);
ConfigurableLanguage::createFromLangcode('it')->save();
ConfigurableLanguage::createFromLangcode('fr')->save();
/** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
$field_storage_config = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'type' => 'image',
'entity_type' => $entity_type_id,
'cardinality' => 1,
'translatable' => 1,
]);
$field_storage_config->save();
$field_config = FieldConfig::create([
'entity_type' => $entity_type_id,
'field_name' => $this->fieldName,
'bundle' => $entity_type_id,
'label' => 'Synchronized field',
'translatable' => 1,
]);
$field_config->save();
$property_settings = [
'alt' => 'alt',
'title' => 'title',
'file' => 0,
];
$field_config->setThirdPartySetting('content_translation', 'translation_sync', $property_settings);
$field_config->save();
$this->contentTranslationManager = $this->container
->get('content_translation.manager');
$this->contentTranslationManager
->setEnabled($entity_type_id, $entity_type_id, TRUE);
$this->storage = $this->entityTypeManager
->getStorage($entity_type_id);
foreach ($this->getTestFiles('image') as $file) {
$entity = File::create((array) $file + [
'status' => 1,
]);
$entity->save();
}
$this->state
->set('content_translation.entity_access.file', [
'view' => TRUE,
]);
$account = User::create([
'name' => $this->randomMachineName(),
'status' => 1,
]);
$account->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.