You are here

public function AssetMediaFactoryTest::testGetMediaEntities in Media: Acquia DAM 8

Validate we can retrieve multiple entities by asset ID.

File

tests/src/Unit/AssetMediaFactoryTest.php, line 115

Class

AssetMediaFactoryTest
Class AssetMediaFactoryTest.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

public function testGetMediaEntities() {
  $asset = $this
    ->getAssetData();
  $entities = $this->assetMediaFactory
    ->getMediaEntities($asset->id);
  $this
    ->assertArrayHasKey('acquiadam_asset', $entities);
  $this
    ->assertArrayHasKey('acquiadam_image', $entities);
  $this
    ->assertArrayNotHasKey('acquiadam_other', $entities);
  $this
    ->assertCount(2, $entities);
  $entities = $this->assetMediaFactory
    ->getMediaEntities($asset->id, 'acquiadam_asset');
  $this
    ->assertCount(1, $entities);
  $this
    ->assertArrayHasKey('acquiadam_asset', $entities);
  $this
    ->assertFalse($this->assetMediaFactory
    ->getMediaEntity($asset->id, 'acquiadam_other'));
  $this
    ->assertFalse($this->assetMediaFactory
    ->getMediaEntity(FALSE, 'acquiadam_asset'));
}