You are here

public function ScheduledTransitionTest::testSingleTransition in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8.2 modules/lightning_scheduler/tests/src/Functional/ScheduledTransitionTest.php \Drupal\Tests\lightning_scheduler\Functional\ScheduledTransitionTest::testSingleTransition()

Tests a single scheduled workflow state transition.

@dataProvider providerSingleTransition

Parameters

int $offset: How many seconds in the past or future to schedule the transition. If negative, the transition will be in the past.

string $to_state: The workflow state to transition to.

string $expected_state_label: The label of the workflow state that is expected after the transition is executed.

File

modules/lightning_scheduler/tests/src/Functional/ScheduledTransitionTest.php, line 119

Class

ScheduledTransitionTest
@group lightning_workflow @group lightning_scheduler @group orca_public

Namespace

Drupal\Tests\lightning_scheduler\Functional

Code

public function testSingleTransition($offset, $to_state, $expected_state_label) {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $now = time();
  $this
    ->drupalGet('/node/add/page');
  $assert_session
    ->statusCodeEquals(200);
  $page
    ->fillField('Title', 'Schedule This');
  $this
    ->setTransitionData('moderation_state[0][scheduled_transitions][data]', [
    [
      'when' => $now + $offset,
      'state' => $to_state,
    ],
  ]);
  $page
    ->pressButton('Save');
  $assert_session
    ->addressMatches('/^\\/node\\/[0-9]+$/');
  $edit_url = $this
    ->getUrl() . '/edit';
  if ($offset > 0) {
    $this
      ->setRequestTime($now + $offset + 2);
  }
  $this
    ->cronRun();
  $this
    ->drupalGet($edit_url);
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->pageTextContains("Current state {$expected_state_label}");
}