public function AssetMediaFactoryTest::testGetAssetUsage in Media: Acquia DAM 8
Validate that we can get media entities assets are attached to.
File
- tests/
src/ Unit/ AssetMediaFactoryTest.php, line 138
Class
- AssetMediaFactoryTest
- Class AssetMediaFactoryTest.
Namespace
Drupal\Tests\media_acquiadam\UnitCode
public function testGetAssetUsage() {
$asset = $this
->getAssetData();
$this
->assertArrayHasKey('acquiadam_asset', $this->assetMediaFactory
->getAssetUsage($asset->id));
$this
->assertArrayHasKey('acquiadam_asset', $this->assetMediaFactory
->getAssetUsage($asset->id, 'acquiadam_asset'));
$this
->assertEquals($this->mediaEntity
->id(), $this->assetMediaFactory
->getAssetUsage($asset->id, 'acquiadam_asset')['acquiadam_asset'][0]);
$this
->assertEmpty($this->assetMediaFactory
->getAssetUsage($asset->id, 'acquiadam_other'));
$this
->assertEmpty($this->assetMediaFactory
->getAssetUsage(FALSE, 'acquiadam_asset'));
$this
->assertEmpty($this->assetMediaFactory
->getAssetUsage(FALSE, 'acquiadam_other'));
}