protected function ContentTranslationFieldSyncRevisionTest::assertLatestRevisionFieldValues 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::assertLatestRevisionFieldValues()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::assertLatestRevisionFieldValues()
Asserts that the latest revision has the expected field values.
Parameters
$entity_id: The entity ID.
array $expected_values: An array of expected values in the following order:
- revision ID
- target ID (en)
- target ID (it)
- alt (en)
- alt (it)
1 call to ContentTranslationFieldSyncRevisionTest::assertLatestRevisionFieldValues()
- 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 482
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function assertLatestRevisionFieldValues($entity_id, array $expected_values) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->storage
->loadRevision($this->storage
->getLatestRevisionId($entity_id));
@(list($revision_id, $target_id_en, $target_id_it, $alt_en, $alt_it) = $expected_values);
$this
->assertEquals($revision_id, $entity
->getRevisionId());
$this
->assertEquals($target_id_en, $entity
->get($this->fieldName)->target_id);
$this
->assertEquals($alt_en, $entity
->get($this->fieldName)->alt);
if ($entity
->hasTranslation('it')) {
$it_translation = $entity
->getTranslation('it');
$this
->assertEquals($target_id_it, $it_translation
->get($this->fieldName)->target_id);
$this
->assertEquals($alt_it, $it_translation
->get($this->fieldName)->alt);
}
}