You are here

public function ScheduleIntervalTest::testScheduleIntervals in Webform Scheduled Tasks 8.2

Test the interval scheduling.

@dataProvider scheduleIntervalsTestCases

File

tests/src/Kernel/ScheduleIntervalTest.php, line 50

Class

ScheduleIntervalTest
Test the scheduling intervals.

Namespace

Drupal\Tests\webform_scheduled_tasks\Kernel

Code

public function testScheduleIntervals($entity_values, $expected_next_run) {
  Webform::create([
    'id' => 'foo',
  ])
    ->save();
  $scheduled_task = WebformScheduledTask::create([
    'id' => 'foo',
    'result_set_type' => 'all_submissions',
    'task_type' => 'test_task',
    'webform' => 'foo',
  ] + $entity_values);
  $scheduled_task
    ->save();
  $this
    ->assertEquals($entity_values['interval']['amount'], $scheduled_task
    ->getRunIntervalAmount());
  $this
    ->assertEquals($entity_values['interval']['multiplier'], $scheduled_task
    ->getRunIntervalMultiplier());

  // The next run date will automatically be instantiated to the current time
  // plus the intervals specified.
  $this
    ->assertEquals($expected_next_run, $scheduled_task
    ->getNextTaskRunDate());
}