You are here

public function AcquiadamServiceTest::testGetAsset in Media: Acquia DAM 8

Validates we can fetch an asset.

File

tests/src/Unit/AcquiadamServiceTest.php, line 64

Class

AcquiadamServiceTest
Acquia DAM REST extension tests.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

public function testGetAsset() {
  $asset = $this
    ->getAssetData();

  // No assets should be primed.
  $this
    ->assertNull($this->acquiaDamClient
    ->staticAssetCache('get', $asset->id));

  // Asset should be primed.
  $this
    ->assertInstanceOf(Asset::class, $this->acquiaDamClient
    ->getAsset($asset->id));
  $this
    ->assertInstanceOf(Asset::class, $this->acquiaDamClient
    ->staticAssetCache('get', $asset->id));

  // Simulate a cached failed fetch.
  $this->acquiaDamClient
    ->staticAssetCache('set', $asset->id, FALSE);
  $this
    ->assertFalse($this->acquiaDamClient
    ->getAsset($asset->id));
  $this
    ->assertFalse($this->acquiaDamClient
    ->getAsset(1234567890));
}