function TranslationWebTest::checkTranslationRevisions
Same name in other branches
- 9 core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()
- 8.9.x core/modules/field/tests/src/Functional/TranslationWebTest.php \Drupal\Tests\field\Functional\TranslationWebTest::checkTranslationRevisions()
- 10 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 139
Class
- TranslationWebTest
- Tests multilingual fields logic that require a full environment.
Namespace
Drupal\Tests\field\FunctionalCode
private function checkTranslationRevisions($id, $revision_id, $available_langcodes) : void {
$field_name = $this->fieldStorage
->getName();
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$entity = $storage->loadRevision($revision_id);
foreach ($available_langcodes as $langcode => $value) {
$passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1;
$this->assertTrue($passed, "The {$langcode} translation for revision {$entity->getRevisionId()} was correctly stored");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.