class AssetDataTest in Media: Acquia DAM 8
Tests to validate that the asset data service works as expected.
@group media_acquiadam
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\media_acquiadam\Unit\AssetDataTest uses AcquiadamAssetDataTrait
Expanded class hierarchy of AssetDataTest
File
- tests/
src/ Unit/ AssetDataTest.php, line 16
Namespace
Drupal\Tests\media_acquiadam\UnitView source
class AssetDataTest extends UnitTestCase {
use AcquiadamAssetDataTrait;
/**
* Container builder helper.
*
* @var \Drupal\Core\DependencyInjection\ContainerBuilder
*/
protected $container;
/**
* Media: Acquia DAM asset data service.
*
* Mocked to have a fixed set/get.
*
* @var \Drupal\media_acquiadam\AssetData|\PHPUnit\Framework\MockObject\MockObject
*/
protected $acquiaAssetData;
/**
* Validates that we can correctly determine if an asset has been updated.
*/
public function testIsUpdatedAsset() {
$asset = $this
->getAssetData();
$this
->assertTrue($this->acquiaAssetData
->isUpdatedAsset($asset));
$asset->id = 3455970;
$this
->assertFalse($this->acquiaAssetData
->isUpdatedAsset($asset));
}
/**
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiadamAssetDataTrait:: |
protected | function | Create a new version of a given asset. | |
AcquiadamAssetDataTrait:: |
protected | function | Returns an Asset object for testing against. | |
AssetDataTest:: |
protected | property | Media: Acquia DAM asset data service. | |
AssetDataTest:: |
protected | property | Container builder helper. | |
AssetDataTest:: |
protected | function |
Overrides UnitTestCase:: |
|
AssetDataTest:: |
public | function | Validates that we can correctly determine if an asset has been updated. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |