function TranslationWebTest::checkTranslationRevisions

Same name in other branches
  1. 8.9.x core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()
  2. 10 core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()
  3. 11.x core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()

Tests translation revisions.

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

1 call to TranslationWebTest::checkTranslationRevisions()
TranslationWebTest::testFieldFormTranslationRevisions in core/modules/field/tests/src/Functional/TranslationWebTest.php
Tests field translations when creating a new revision.

File

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

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(),
        ]));
    }
}

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