function EntityRevisionTranslationTest::testNewRevisionAfterTranslation
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testNewRevisionAfterTranslation()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testNewRevisionAfterTranslation()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testNewRevisionAfterTranslation()
Tests if the translation object has the right revision id after new revision.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityRevisionTranslationTest.php, line 38
Class
- EntityRevisionTranslationTest
- Tests proper revision propagation of entities.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testNewRevisionAfterTranslation() {
$user = $this->createUser();
// Create a test entity.
$entity = EntityTestMulRev::create([
'name' => $this->randomString(),
'user_id' => $user->id(),
'language' => 'en',
]);
$entity->save();
$old_rev_id = $entity->getRevisionId();
$translation = $entity->addTranslation('de');
$translation->setNewRevision();
$translation->save();
// Verify that the saved translation for the new translation has a newer
// revision ID.
$this->assertGreaterThan($old_rev_id, $translation->getRevisionId());
// Verify that the entity from the storage has a newer revision ID.
$this->assertGreaterThan($old_rev_id, $this->reloadEntity($entity)
->getRevisionId());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.