function ContentTranslationFieldSyncRevisionTest::assertLatestRevisionFieldValues
Same name in other branches
- 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::assertLatestRevisionFieldValues()
- 8.9.x 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.
@internal
Parameters
string $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 566
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function assertLatestRevisionFieldValues(string $entity_id, array $expected_values) : void {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->storage
->loadRevision($this->storage
->getLatestRevisionId($entity_id));
@([
$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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.