public function ScheduledTransitionTest::testScheduledTransitionEntityCleanUp in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/ScheduledTransitionTest.php \Drupal\Tests\scheduled_transitions\Kernel\ScheduledTransitionTest::testScheduledTransitionEntityCleanUp()
Test scheduled transitions are cleaned up when entities are deleted.
File
- tests/
src/ Kernel/ ScheduledTransitionTest.php, line 332
Class
- ScheduledTransitionTest
- Tests basic functionality of scheduled_transitions fields.
Namespace
Drupal\Tests\scheduled_transitions\KernelCode
public function testScheduledTransitionEntityCleanUp() {
$workflow = $this
->createEditorialWorkflow();
$workflow
->getTypePlugin()
->addEntityTypeAndBundle('entity_test_revlog', 'entity_test_revlog');
$workflow
->save();
$entity = EntityTestWithRevisionLog::create([
'type' => 'entity_test_revlog',
'name' => 'foo',
'moderation_state' => 'draft',
]);
$entity
->save();
$scheduledTransition = ScheduledTransition::create([
'entity' => $entity,
'entity_revision_id' => $entity
->getRevisionId(),
'author' => 1,
'workflow' => $workflow
->id(),
'moderation_state' => 'published',
'transition_on' => (new \DateTime('2 Feb 2018 11am'))
->getTimestamp(),
'options' => [
[
'recreate_non_default_head' => TRUE,
],
],
]);
$scheduledTransition
->save();
$entity
->delete();
$this
->assertNull(ScheduledTransition::load($scheduledTransition
->id()));
}