function EntityRevisionsTest::testDefaultRevisionFlag
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testDefaultRevisionFlag()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testDefaultRevisionFlag()
Tests the automatic handling of the "revision_default" flag.
@covers \Drupal\Core\Entity\ContentEntityStorageBase::doSave
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityRevisionsTest.php, line 269
Class
- EntityRevisionsTest
- Tests the loaded Revision of an entity.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testDefaultRevisionFlag() : void {
// Create a basic EntityTestMulRev entity and save it.
$entity = EntityTestMulRev::create();
$entity->save();
$this->assertTrue($entity->wasDefaultRevision());
// Create a new default revision.
$entity->setNewRevision(TRUE);
$entity->save();
$this->assertTrue($entity->wasDefaultRevision());
// Create a new non-default revision.
$entity->setNewRevision(TRUE);
$entity->isDefaultRevision(FALSE);
$entity->save();
$this->assertFalse($entity->wasDefaultRevision());
// Turn the previous non-default revision into a default revision.
$entity->isDefaultRevision(TRUE);
$entity->save();
$this->assertTrue($entity->wasDefaultRevision());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.