You are here

trait AcquiadamAssetImageHelperTrait in Media: Acquia DAM 8

Shared methods for dealing with a mocked AssetImageHelper.

Hierarchy

1 file declares its use of AcquiadamAssetImageHelperTrait
AssetFileEntityHelperTest.php in tests/src/Unit/AssetFileEntityHelperTest.php

File

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

Namespace

Drupal\Tests\media_acquiadam\Traits
View source
trait AcquiadamAssetImageHelperTrait {

  /**
   * Create a stub AssetImageHelper that implements some basic functions.
   *
   * @return \Drupal\media_acquiadam\Service\AssetImageHelper|\PHPUnit\Framework\MockObject\MockObject
   *   The stubbed service.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiadamAssetImageHelperTrait::getAssetImageHelperStub public function Create a stub AssetImageHelper that implements some basic functions.