You are here

protected function AssetImageHelperTest::getMockedAssetImageHelper in Media: Acquia DAM 8

Gets a mocked version of the AssetImageHelper class.

This is used to provide some implemented methods that would normally be an issue to test.

Return value

\Drupal\media_acquiadam\Service\AssetImageHelper|\PHPUnit\Framework\MockObject\MockObject A mocked AssetImageHelper object.

2 calls to AssetImageHelperTest::getMockedAssetImageHelper()
AssetImageHelperTest::setUp in tests/src/Unit/AssetImageHelperTest.php
AssetImageHelperTest::testGetGenericMediaIcon in tests/src/Unit/AssetImageHelperTest.php
Validate we get a generic media icon when no image can be loaded.

File

tests/src/Unit/AssetImageHelperTest.php, line 164

Class

AssetImageHelperTest
Tests integration of the AssetImageHelper service.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

protected function getMockedAssetImageHelper() {
  $helper = $this
    ->getMockBuilder(AssetImageHelper::class)
    ->setConstructorArgs([
    $this->container
      ->get('config.factory'),
    $this->container
      ->get('file_system'),
    $this->container
      ->get('http_client'),
    $this->container
      ->get('file.mime_type.guesser'),
    $this->container
      ->get('image.factory'),
  ])
    ->setMethods([
    'phpFileExists',
    'getAcquiaDamModulePath',
    'saveFallbackThumbnail',
  ])
    ->getMock();
  $helper
    ->method('getAcquiaDamModulePath')
    ->willReturn('modules/contrib/media_acquiadam');
  $helper
    ->method('saveFallbackThumbnail')
    ->willReturn(NULL);
  return $helper;
}