You are here

protected function AcquiadamKernelTestBase::createMedia in Media: Acquia DAM 8

Creates a media entity with a given Asset ID.

Parameters

int $asset_id: The asset ID.

string $bundle: The media entity.

Return value

\Drupal\Core\Entity\EntityInterface|\Drupal\media\Entity\Media The created media entity.

Throws

\Drupal\Core\Entity\EntityStorageException

2 calls to AcquiadamKernelTestBase::createMedia()
AcquiadamMediaTest::setUp in tests/src/Kernel/AcquiadamMediaTest.php
AcquiadamMediaTest::testAssetFileIsCorrect in tests/src/Kernel/AcquiadamMediaTest.php
Tests if updating multiple revisionable entities.

File

tests/src/Kernel/AcquiadamKernelTestBase.php, line 91

Class

AcquiadamKernelTestBase
Base class for Acquia DAM kernel tests.

Namespace

Drupal\Tests\media_acquiadam\Kernel

Code

protected function createMedia(int $asset_id, string $bundle = self::DEFAULT_BUNDLE) {
  $media = Media::create([
    'bundle' => $bundle,
    'field_acquiadam_asset_id' => $asset_id,
  ]);
  $media
    ->save();
  return $media;
}