You are here

protected function MediaEntityFileReplaceTest::loadMediaEntityByName in Media Entity File Replace 8

Load a single media entity by name, ignoring object cache.

1 call to MediaEntityFileReplaceTest::loadMediaEntityByName()
MediaEntityFileReplaceTest::testModule in tests/src/Functional/MediaEntityFileReplaceTest.php
Tests basic functionality of the module.

File

tests/src/Functional/MediaEntityFileReplaceTest.php, line 212

Class

MediaEntityFileReplaceTest
Class MediaEntityFileReplaceTest.

Namespace

Drupal\Tests\media_entity_file_replace\Functional

Code

protected function loadMediaEntityByName($name) {
  $mediaStorage = \Drupal::entityTypeManager()
    ->getStorage('media');
  $mediaStorage
    ->resetCache();
  $entities = $mediaStorage
    ->loadByProperties([
    'name' => $name,
  ]);
  $this
    ->assertNotEmpty($entities, "No media entity with name {$name} was found.");
  return array_pop($entities);
}