function EntityRevisionTranslationTest::testDefaultRevision
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testDefaultRevision()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testDefaultRevision()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testDefaultRevision()
Tests changing the default revision flag is propagated to all translations.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityRevisionTranslationTest.php, line 144
Class
- EntityRevisionTranslationTest
- Tests proper revision propagation of entities.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testDefaultRevision() {
// Create a test entity with a translation, which will internally trigger
// entity cloning for the new translation and create references for some of
// the entity properties.
$entity = EntityTestMulRev::create([
'name' => 'original',
'language' => 'en',
]);
$translation = $entity->addTranslation('de');
$entity->save();
// Assert that the entity is in the default revision.
$this->assertTrue($entity->isDefaultRevision());
$this->assertTrue($translation->isDefaultRevision());
// Change the default revision flag on one of the entity translations and
// assert that the change is propagated to all entity translation objects.
$translation->isDefaultRevision(FALSE);
$this->assertFalse($entity->isDefaultRevision());
$this->assertFalse($translation->isDefaultRevision());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.