protected function ContentTranslationFieldSyncRevisionTest::saveNewEntity in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::saveNewEntity()
- 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::saveNewEntity()
Return value
\Drupal\Core\Entity\ContentEntityInterface
File
- core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php, line 404
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function saveNewEntity() {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = EntityTestMulRev::create([
'uid' => 1,
'langcode' => 'en',
$this->fieldName => [
'target_id' => 1,
'alt' => 'Alt 1 EN',
],
]);
$metadata = $this->contentTranslationManager
->getTranslationMetadata($entity);
$metadata
->setSource(LanguageInterface::LANGCODE_NOT_SPECIFIED);
$violations = $entity
->validate();
$this
->assertEmpty($violations);
$this->storage
->save($entity);
return $entity;
}