You are here

protected function MediaCacheTagsTest::createEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Functional/MediaCacheTagsTest.php \Drupal\Tests\media\Functional\MediaCacheTagsTest::createEntity()
  2. 10 core/modules/media/tests/src/Functional/MediaCacheTagsTest.php \Drupal\Tests\media\Functional\MediaCacheTagsTest::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityCacheTagsTestBase::createEntity

File

core/modules/media/tests/src/Functional/MediaCacheTagsTest.php, line 47

Class

MediaCacheTagsTest
Tests the media items cache tags.

Namespace

Drupal\Tests\media\Functional

Code

protected function createEntity() {

  // Create a media type.
  $mediaType = $this
    ->createMediaType('test');

  // Create a media item.
  $media = Media::create([
    'bundle' => $mediaType
      ->id(),
    'name' => 'Unnamed',
  ]);
  $media
    ->save();
  return $media;
}