You are here

protected function MediaRevisionsTestBase::loadOldestRevisionId in Media Revisions UI 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/MediaRevisionsTestBase.php \Drupal\Tests\media_revisions_ui\Functional\MediaRevisionsTestBase::loadOldestRevisionId()

Loads oldest revision from media.

Parameters

\Drupal\Core\Entity\EntityInterface $media: The media from which to load revision.

Return value

\Drupal\Core\Entity\EntityInterface The revision entity.

1 call to MediaRevisionsTestBase::loadOldestRevisionId()
MediaRevisionsUiAccessTest::testOperationsAccess in tests/src/Functional/MediaRevisionsUiAccessTest.php
Tests access of revision operations.

File

tests/src/Functional/MediaRevisionsTestBase.php, line 74

Class

MediaRevisionsTestBase
Provides base class with common methods to use in tests.

Namespace

Drupal\Tests\media_revisions_ui\Functional

Code

protected function loadOldestRevisionId(EntityInterface $media) {
  $result = $this->mediaStorage
    ->getQuery()
    ->allRevisions()
    ->condition('mid', $media
    ->id())
    ->sort('vid', 'ASC')
    ->range(NULL, 1)
    ->execute();
  $revisionId = array_keys($result) ? array_keys($result)[0] : NULL;
  return $this->mediaStorage
    ->loadRevision($revisionId);
}