function EntityDecoupledTranslationRevisionsTest::testMultipleTranslationChanges
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest::testMultipleTranslationChanges()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest::testMultipleTranslationChanges()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest::testMultipleTranslationChanges()
Checks that changes to multiple translations are handled correctly.
@covers ::createRevision @covers \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::validate
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDecoupledTranslationRevisionsTest.php, line 501
Class
- EntityDecoupledTranslationRevisionsTest
- Test decoupled translation revisions.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testMultipleTranslationChanges() {
// Configure the untranslatable fields edit mode.
$this->state
->set('entity_test.untranslatable_fields.default_translation_affected', TRUE);
$this->bundleInfo
->clearCachedBundles();
$entity = EntityTestMulRev::create();
$entity->get('name')->value = 'Test 1.1 EN';
$entity->get('non_mul_field')->value = 'Test 1.1';
$this->storage
->save($entity);
/** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
$revision = $this->storage
->createRevision($entity->addTranslation('it'));
$revision->get('name')->value = 'Test 1.2 IT';
$this->storage
->save($revision);
$revision = $this->storage
->createRevision($revision->getTranslation('en'), FALSE);
$revision->get('non_mul_field')->value = 'Test 1.3';
$revision->getTranslation('it')
->get('name')->value = 'Test 1.3 IT';
$violations = $revision->validate();
$this->assertCount(1, $violations);
$this->assertEquals('Non-translatable fields can only be changed when updating the original language.', $violations[0]->getMessage());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.