You are here

protected function SchedulerRevisioningTest::assertRevisionCount in Scheduler 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/SchedulerRevisioningTest.php \Drupal\Tests\scheduler\Functional\SchedulerRevisioningTest::assertRevisionCount()

Check if the number of revisions for an entity matches a given value.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check.

int $expected: The expected number of revisions.

string $message: The message to display along with the assertion.

1 call to SchedulerRevisioningTest::assertRevisionCount()
SchedulerRevisioningTest::testNewRevision in tests/src/Functional/SchedulerRevisioningTest.php
Tests the creation of new revisions on scheduling.

File

tests/src/Functional/SchedulerRevisioningTest.php, line 46

Class

SchedulerRevisioningTest
Tests revision options when Scheduler publishes or unpublishes content.

Namespace

Drupal\Tests\scheduler\Functional

Code

protected function assertRevisionCount(EntityInterface $entity, int $expected, string $message = '') {
  if (!$entity
    ->getEntityType()
    ->isRevisionable()) {
    return;
  }

  // Because we are not deleting any revisions we can take a short cut and use
  // getLatestRevisionId() which will effectively be the number of revisions.
  $storage = $this
    ->entityStorageObject($entity
    ->getEntityTypeId());
  $count = $storage
    ->getLatestRevisionId($entity
    ->id());
  $this
    ->assertEquals($expected, (int) $count, $message);
}