You are here

public function ContentEntityBaseUnitTest::testIsDefaultRevision in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testIsDefaultRevision()

@covers ::isDefaultRevision

File

core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php, line 268

Class

ContentEntityBaseUnitTest
@coversDefaultClass \Drupal\Core\Entity\ContentEntityBase @group Entity @group Access

Namespace

Drupal\Tests\Core\Entity

Code

public function testIsDefaultRevision() {

  // The default value is TRUE.
  $this
    ->assertTrue($this->entity
    ->isDefaultRevision());

  // Change the default revision, verify that the old value is returned.
  $this
    ->assertTrue($this->entity
    ->isDefaultRevision(FALSE));

  // The last call changed the return value for this call.
  $this
    ->assertFalse($this->entity
    ->isDefaultRevision());

  // The revision for a new entity should always be the default revision.
  $this->entity
    ->expects($this
    ->any())
    ->method('isNew')
    ->will($this
    ->returnValue(TRUE));
  $this->entity
    ->isDefaultRevision(FALSE);
  $this
    ->assertTrue($this->entity
    ->isDefaultRevision());
}