AssetDataTest.php in Media: Acquia DAM 8
File
tests/src/Unit/AssetDataTest.php
View source
<?php
namespace Drupal\Tests\media_acquiadam\Unit;
use Drupal\Core\Database\Connection;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\media_acquiadam\AssetData;
use Drupal\Tests\media_acquiadam\Traits\AcquiadamAssetDataTrait;
use Drupal\Tests\UnitTestCase;
class AssetDataTest extends UnitTestCase {
use AcquiadamAssetDataTrait;
protected $container;
protected $acquiaAssetData;
public function testIsUpdatedAsset() {
$asset = $this
->getAssetData();
$this
->assertTrue($this->acquiaAssetData
->isUpdatedAsset($asset));
$asset->id = 3455970;
$this
->assertFalse($this->acquiaAssetData
->isUpdatedAsset($asset));
}
protected function setUp() {
parent::setUp();
$connection = $this
->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
$asset_data = $this
->getMockBuilder(AssetData::class)
->disableOriginalConstructor()
->setMethods([
'get',
'set',
])
->getMock();
$asset_data
->method('get')
->willReturnMap([
[
3455969,
'version',
3,
],
[
3455970,
'version',
4,
],
]);
$this->acquiaAssetData = $asset_data;
$this->container = new ContainerBuilder();
$this->container
->set('database', $connection);
\Drupal::setContainer($this->container);
}
}
Classes
Name |
Description |
AssetDataTest |
Tests to validate that the asset data service works as expected. |