You are here

public function ScheduledTransitionTest::testSingleTransitionWithPendingRevision in Lightning Scheduler 8

Tests that scheduled transitions work correctly with pending revisions.

@depends testSingleTransition

File

tests/src/Functional/ScheduledTransitionTest.php, line 209

Class

ScheduledTransitionTest
@group lightning_scheduler

Namespace

Drupal\Tests\lightning_scheduler\Functional

Code

public function testSingleTransitionWithPendingRevision() {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $now = time();
  $this
    ->drupalGet('/node/add/page');
  $assert_session
    ->statusCodeEquals(200);
  $page
    ->fillField('Title', 'Schedule This');
  $page
    ->selectFieldOption('moderation_state[0][state]', 'Published');
  $page
    ->pressButton('Save');
  $assert_session
    ->addressMatches('/^\\/node\\/[0-9]+$/');
  $edit_url = $this
    ->getUrl() . '/edit';
  $this
    ->drupalGet($edit_url);
  $page
    ->fillField('Title', 'MC Hammer');
  $page
    ->selectFieldOption('moderation_state[0][state]', 'Draft');
  $this
    ->setTransitionData('moderation_state[0][scheduled_transitions][data]', [
    [
      'when' => $now + 10,
      'state' => 'published',
    ],
  ]);
  $page
    ->pressButton('Save');
  $this
    ->setRequestTime($now + 12);
  $this
    ->cronRun();
  $this
    ->drupalGet($edit_url);
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->fieldValueEquals('Title', 'MC Hammer');
}