You are here

public function AcquiadamAssetImageHelperTrait::getAssetImageHelperStub in Media: Acquia DAM 8

Create a stub AssetImageHelper that implements some basic functions.

Return value

\Drupal\media_acquiadam\Service\AssetImageHelper|\PHPUnit\Framework\MockObject\MockObject The stubbed service.

File

tests/src/Traits/AcquiadamAssetImageHelperTrait.php, line 18

Class

AcquiadamAssetImageHelperTrait
Shared methods for dealing with a mocked AssetImageHelper.

Namespace

Drupal\Tests\media_acquiadam\Traits

Code

public function getAssetImageHelperStub() {
  $asset_image_helper = $this
    ->getMockBuilder(AssetImageHelper::class)
    ->disableOriginalConstructor()
    ->getMock();
  $asset_image_helper
    ->method('getMimeTypeFromFileType')
    ->willReturnMap([
    [
      'jpg',
      [
        'discrete' => 'image',
        'sub' => 'jpg',
      ],
    ],
    [
      'mov',
      [
        'discrete' => 'quicktime',
        'sub' => 'mov',
      ],
    ],
    [
      'pdf',
      [
        'discrete' => 'application',
        'sub' => 'pdf',
      ],
    ],
  ]);
  $asset_image_helper
    ->method('getThumbnailUrlBySize')
    ->willReturn('http://subdomain.webdamdb.com/s/310th_sm_0UerYozlI3.jpg');
  return $asset_image_helper;
}