function MediaRevisionTest::assertRevisionCount

Same name in other branches
  1. 9 core/modules/media/tests/src/Functional/MediaRevisionTest.php \Drupal\Tests\media\Functional\MediaRevisionTest::assertRevisionCount()
  2. 10 core/modules/media/tests/src/Functional/MediaRevisionTest.php \Drupal\Tests\media\Functional\MediaRevisionTest::assertRevisionCount()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.