public function AssetCRUDTest::testArchiveAsset in farmOS 2.x
Asset archiving.
File
- modules/
core/ asset/ tests/ src/ Functional/ AssetCRUDTest.php, line 112
Class
- AssetCRUDTest
- Tests the asset CRUD.
Namespace
Drupal\Tests\asset\FunctionalCode
public function testArchiveAsset() {
$asset = $this
->createAssetEntity();
$asset
->save();
$this
->assertEquals($asset
->get('status')
->first()
->getString(), 'active', 'New assets are active by default');
$this
->assertNull($asset
->getArchivedTime(), 'Archived timestamp is null by default');
$asset
->get('status')
->first()
->applyTransitionById('archive');
$asset
->save();
$this
->assertEquals($asset
->get('status')
->first()
->getString(), 'archived', 'Assets can be archived');
$this
->assertNotNull($asset
->getArchivedTime(), 'Archived timestamp is saved');
$asset
->get('status')
->first()
->applyTransitionById('to_active');
$asset
->save();
$this
->assertEquals($asset
->get('status')
->first()
->getString(), 'active', 'Assets can be made active');
$this
->assertNull($asset
->getArchivedTime(), 'Asset made active has a null timestamp');
$asset
->get('status')
->first()
->applyTransitionById('archive');
$asset
->setArchivedTime('2021-07-17T19:45:49+00:00');
$asset
->save();
$this
->assertEquals($asset
->get('status')
->first()
->getString(), 'archived', 'Assets can be archived with explicit timestamp');
$this
->assertEquals($asset
->getArchivedTime(), '2021-07-17T19:45:49+00:00', 'Explicit archived timestamp is saved');
}