protected function ContentTranslationFieldSyncRevisionTest::saveNewEntity in Drupal 8
Same name and namespace in other branches
- 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::saveNewEntity()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::saveNewEntity()
Return value
\Drupal\Core\Entity\ContentEntityInterface
2 calls to ContentTranslationFieldSyncRevisionTest::saveNewEntity()
- ContentTranslationFieldSyncRevisionTest::testChangeDefaultLanguageNonTranslatableFieldsHidden in core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php - Test changing the default language of an entity.
- ContentTranslationFieldSyncRevisionTest::testFieldSynchronizationAndValidation in core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php - Checks that field synchronization works as expected with revisions.
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;
}