You are here

protected function AssetFileEntityHelperTest::getMockedAssetFileEntityHelper in Media: Acquia DAM 8

Get a mocked AssetFileEntityHelper that stubs file operations.

Return value

\Drupal\media_acquiadam\Service\AssetFileEntityHelper|\PHPUnit\Framework\MockObject\MockObject The mocked AssetFileEntityHelper class.

1 call to AssetFileEntityHelperTest::getMockedAssetFileEntityHelper()
AssetFileEntityHelperTest::setUp in tests/src/Unit/AssetFileEntityHelperTest.php

File

tests/src/Unit/AssetFileEntityHelperTest.php, line 203

Class

AssetFileEntityHelperTest
Tests to validate that our file entity helper works as expected.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

protected function getMockedAssetFileEntityHelper() {
  $helper = $this
    ->getMockBuilder(AssetFileEntityHelper::class)
    ->setConstructorArgs([
    $this->container
      ->get('entity_type.manager'),
    $this->container
      ->get('entity_field.manager'),
    $this->container
      ->get('config.factory'),
    $this->container
      ->get('file_system'),
    $this->container
      ->get('token'),
    $this->container
      ->get('media_acquiadam.asset_image.helper'),
    $this->container
      ->get('media_acquiadam.acquiadam'),
    $this->container
      ->get('media_acquiadam.asset_media.factory'),
    $this->container
      ->get('logger.factory'),
  ])
    ->setMethods([
    'phpFileGetContents',
    'drupalFileSaveData',
  ])
    ->getMock();
  $helper
    ->method('phpFileGetContents')
    ->willReturn('File contents');
  $helper
    ->method('drupalFileSaveData')
    ->willReturn($this->mockedFileEntity);
  return $helper;
}