function MediaRevisionTest::createMedia

Same name in other branches
  1. 11.x core/modules/media/tests/src/Functional/MediaRevisionTest.php \Drupal\Tests\media\Functional\MediaRevisionTest::createMedia()

Creates a media item.

Parameters

string $title: Title of media item.

Return value

\Drupal\media\Entity\Media A media item.

3 calls to MediaRevisionTest::createMedia()
MediaRevisionTest::testRevisionDelete in core/modules/media/tests/src/Functional/MediaRevisionTest.php
Tests deleting a revision.
MediaRevisionTest::testRevisionRevert in core/modules/media/tests/src/Functional/MediaRevisionTest.php
Tests reverting a revision.
MediaRevisionTest::testRevisions in core/modules/media/tests/src/Functional/MediaRevisionTest.php
Checks media revision operations.

File

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

Class

MediaRevisionTest
Tests the revisions of media entities.

Namespace

Drupal\Tests\media\Functional

Code

protected function createMedia(string $title) : Media {
    $media = Media::create([
        'bundle' => 'test',
        'name' => $title,
    ]);
    $media->save();
    return $media;
}

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