You are here

private function TranslationWebTest::checkTranslationRevisions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()
  2. 9 core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()

Check if the field translation attached to the entity revision identified by the passed arguments were correctly stored.

File

core/modules/field/tests/src/Functional/TranslationWebTest.php, line 135

Class

TranslationWebTest
Tests multilanguage fields logic that require a full environment.

Namespace

Drupal\Tests\field\Functional

Code

private function checkTranslationRevisions($id, $revision_id, $available_langcodes) {
  $field_name = $this->fieldStorage
    ->getName();
  $entity = $this->container
    ->get('entity_type.manager')
    ->getStorage($this->entityTypeId)
    ->loadRevision($revision_id);
  foreach ($available_langcodes as $langcode => $value) {
    $passed = $entity
      ->getTranslation($langcode)->{$field_name}->value == $value + 1;
    $this
      ->assertTrue($passed, new FormattableMarkup('The @language translation for revision @revision was correctly stored', [
      '@language' => $langcode,
      '@revision' => $entity
        ->getRevisionId(),
    ]));
  }
}