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