You are here

protected function MediaEntityHelperTest::setMockedAcquiaDamServices in Media: Acquia DAM 8

Sets Media: Acquia DAM mocked services into a container.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: The container to set mocks into.

1 call to MediaEntityHelperTest::setMockedAcquiaDamServices()
MediaEntityHelperTest::setUp in tests/src/Unit/MediaEntityHelperTest.php

File

tests/src/Unit/MediaEntityHelperTest.php, line 205

Class

MediaEntityHelperTest
Testing of the Media Entity helper class.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

protected function setMockedAcquiaDamServices(ContainerBuilder $container) {
  $asset_data = $this
    ->getMockBuilder(AssetData::class)
    ->disableOriginalConstructor()
    ->getMock();
  $asset_data
    ->method('isUpdatedAsset')
    ->willReturnOnConsecutiveCalls(FALSE, TRUE);
  $acquiadam = $this
    ->getMockBuilder(Acquiadam::class)
    ->disableOriginalConstructor()
    ->getMock();
  $acquiadam
    ->method('getAsset')
    ->willReturnMap([
    [
      $this
        ->getAssetData()->id,
      TRUE,
      $this
        ->getAssetData(),
    ],
  ]);
  $asset_file_helper = $this
    ->getMockBuilder(AssetFileEntityHelper::class)
    ->disableOriginalConstructor()
    ->getMock();
  $asset_file_helper
    ->method('getDestinationFromEntity')
    ->willReturn('private://assets/replaced');
  $asset_file_helper
    ->method('createNewFile')
    ->with($this
    ->anything(), 'private://assets/replaced')
    ->willReturn($this
    ->getMockedFileEntity());
  $container
    ->set('media_acquiadam.asset_data', $asset_data);
  $container
    ->set('media_acquiadam.acquiadam', $acquiadam);
  $container
    ->set('media_acquiadam.asset_file.helper', $asset_file_helper);
}