You are here

private function CkEditorMediaBrowserTest::addMedia in Lightning Media 8.2

Adds a media item to the library and marks it for deletion in tearDown().

Parameters

array $values: The values with which to create the media item.

Return value

\Drupal\media\MediaInterface The saved media item.

3 calls to CkEditorMediaBrowserTest::addMedia()
CkEditorMediaBrowserTest::setUp in tests/src/ExistingSiteJavascript/CkEditorMediaBrowserTest.php
CkEditorMediaBrowserTest::testDocumentEmbed in tests/src/ExistingSiteJavascript/CkEditorMediaBrowserTest.php
Tests that the image embed plugin is not used to embed a document.
CkEditorMediaBrowserTest::testImageEmbed in tests/src/ExistingSiteJavascript/CkEditorMediaBrowserTest.php
Tests that the image embed plugin is used to embed an image.

File

tests/src/ExistingSiteJavascript/CkEditorMediaBrowserTest.php, line 269

Class

CkEditorMediaBrowserTest
@group lightning @group lightning_media

Namespace

Drupal\Tests\lightning_media\ExistingSiteJavascript

Code

private function addMedia(array $values) {

  /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('media');
  $values += [
    'name' => $this
      ->randomString(),
  ];

  /** @var \Drupal\media\MediaInterface $media */
  $media = $storage
    ->create($values);
  $media
    ->set('field_media_in_library', TRUE)
    ->setPublished();
  $this
    ->assertSame(SAVED_NEW, $storage
    ->save($media));
  array_push($this->media, $media);
  return $media;
}