You are here

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

Overrides UnitTestCase::setUp

File

tests/src/Unit/AssetMetadataHelperTest.php, line 168

Class

AssetMetadataHelperTest
Tests integration of the AssetMetadataHelper service.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

protected function setUp() {
  parent::setUp();
  $date_formatter = $this
    ->getMockBuilder(DateFormatterInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $date_formatter
    ->method('format')
    ->willReturnCallback(function ($timestamp, $type, $format) {
    if ('custom' == $type) {
      $dt = new \DateTime('now', new \DateTimeZone('UTC'));
      $dt
        ->setTimestamp($timestamp);
      return $dt
        ->format($format);
    }
    return FALSE;
  });
  $acquiadam_client = $this
    ->getMockBuilder(Acquiadam::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'getActiveXmpFields',
  ])
    ->getMock();
  $acquiadam_client
    ->method('getActiveXmpFields')
    ->willReturn([]);
  $this->container = new ContainerBuilder();
  $this->container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  $this->container
    ->set('date.formatter', $date_formatter);
  $this->container
    ->set('media_acquiadam.acquiadam', $acquiadam_client);
  \Drupal::setContainer($this->container);
  $this->assetMetadataHelper = AssetMetadataHelper::create($this->container);
}