You are here

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

Overrides UnitTestCase::setUp

File

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

Class

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

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

protected function setUp() {
  parent::setUp();
  $this->mockedFileEntity = $this
    ->getMockBuilder(FileInterface::class)
    ->disableOriginalConstructor()
    ->getMockForAbstractClass();
  $this->mockedFileEntity
    ->method('id')
    ->willReturn(333);
  $acquiadam = $this
    ->getMockBuilder(Acquiadam::class)
    ->disableOriginalConstructor()
    ->getMock();
  $asset_media_factory = $this
    ->getMockBuilder(AssetMediaFactory::class)
    ->disableOriginalConstructor()
    ->getMock();
  $asset_media_factory
    ->method('getFileEntity')
    ->willReturn($this->mockedFileEntity
    ->id());
  $this->container = new ContainerBuilder();
  $this
    ->setMockedDrupalServices($this->container);
  $this->container
    ->set('media_acquiadam.asset_image.helper', $this
    ->getAssetImageHelperStub());
  $this->container
    ->set('media_acquiadam.acquiadam', $acquiadam);
  $this->container
    ->set('media_acquiadam.asset_media.factory', $asset_media_factory);
  $this->container
    ->set('logger.factory', $this
    ->getLoggerFactoryStub());
  \Drupal::setContainer($this->container);
  $this->assetFileEntityHelper = $this
    ->getMockedAssetFileEntityHelper();
}