function ContentTranslationFieldSyncRevisionTest::saveNewEntity

Same name in other branches
  1. 8.9.x core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::saveNewEntity()
  2. 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::saveNewEntity()
  3. 11.x 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
Tests 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\Kernel

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.