public function ScheduledTransitionTest::testSingleTransition in Lightning Scheduler 8
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
- tests/
src/ Functional/ ScheduledTransitionTest.php, line 104
Class
- ScheduledTransitionTest
- @group lightning_scheduler
Namespace
Drupal\Tests\lightning_scheduler\FunctionalCode
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}");
}