public function AssetCRUDTest::testArchiveAssetViaTimestamp in farmOS 2.x
Asset archiving/unarchiving via timestamp.
File
- modules/
core/ asset/ tests/ src/ Functional/ AssetCRUDTest.php, line 142
Class
- AssetCRUDTest
- Tests the asset CRUD.
Namespace
Drupal\Tests\asset\FunctionalCode
public function testArchiveAssetViaTimestamp() {
$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
->setArchivedTime('2021-07-17T19:45:49+00:00');
$asset
->save();
$this
->assertEquals($asset
->get('status')
->first()
->getString(), 'archived', 'Assets can be archived');
$this
->assertEquals($asset
->getArchivedTime(), '2021-07-17T19:45:49+00:00', 'Archived timestamp is saved');
$asset
->setArchivedTime(NULL);
$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');
}