You are here

protected function MediaRevisionTest::assertRevisionCount in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/tests/src/Functional/MediaRevisionTest.php \Drupal\Tests\media\Functional\MediaRevisionTest::assertRevisionCount()

Asserts that an entity has a certain number of revisions.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity in question.

int $expected_revisions: The expected number of revisions.

2 calls to MediaRevisionTest::assertRevisionCount()
MediaRevisionTest::testFileMediaRevision in core/modules/media/tests/src/Functional/MediaRevisionTest.php
Tests creating revisions of a File media item.
MediaRevisionTest::testImageMediaRevision in core/modules/media/tests/src/Functional/MediaRevisionTest.php
Tests creating revisions of a Image media item.

File

core/modules/media/tests/src/Functional/MediaRevisionTest.php, line 194

Class

MediaRevisionTest
Tests the revisionability of media entities.

Namespace

Drupal\Tests\media\Functional

Code

protected function assertRevisionCount(EntityInterface $entity, $expected_revisions) {
  $entity_type = $entity
    ->getEntityType();
  $count = $this->container
    ->get('entity_type.manager')
    ->getStorage($entity_type
    ->id())
    ->getQuery()
    ->count()
    ->allRevisions()
    ->condition($entity_type
    ->getKey('id'), $entity
    ->id())
    ->execute();
  $this
    ->assertSame($expected_revisions, (int) $count);
}