function EntityRevisionsTest::testIsLatestRevision
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testIsLatestRevision()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testIsLatestRevision()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testIsLatestRevision()
Tests that latest revisions are working as expected.
@covers ::isLatestRevision
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityRevisionsTest.php, line 176
Class
- EntityRevisionsTest
- Tests the loaded Revision of an entity.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testIsLatestRevision() : void {
// Create a basic EntityTestMulRev entity and save it.
$entity = EntityTestMulRev::create();
$entity->save();
$this->assertTrue($entity->isLatestRevision());
// Load the created entity and create a new pending revision.
$pending_revision = EntityTestMulRev::load($entity->id());
$pending_revision->setNewRevision(TRUE);
$pending_revision->isDefaultRevision(FALSE);
// The pending revision should still be marked as the latest one before it
// is saved.
$this->assertTrue($pending_revision->isLatestRevision());
$pending_revision->save();
$this->assertTrue($pending_revision->isLatestRevision());
// Load the default revision and check that it is not marked as the latest
// revision.
$default_revision = EntityTestMulRev::load($entity->id());
$this->assertFalse($default_revision->isLatestRevision());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.