You are here

public function ScheduledTransitionTest::testScheduledTransitionEntityCleanUp in Scheduled Transitions 2.x

Same name and namespace in other branches
  1. 8 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 333

Class

ScheduledTransitionTest
Tests basic functionality of scheduled_transitions fields.

Namespace

Drupal\Tests\scheduled_transitions\Kernel

Code

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::createFrom($workflow, 'published', $entity, new \DateTime('2 Feb 2018 11am'), new UserSession([
    'uid' => 1,
  ]))
    ->setOptions([
    [
      'recreate_non_default_head' => TRUE,
    ],
  ]);
  $scheduledTransition
    ->save();
  $entity
    ->delete();
  $this
    ->assertNull(ScheduledTransition::load($scheduledTransition
    ->id()));
}