You are here

public function TaskRunnerTest::testRetryScheduledTaskExceptionThrown in Webform Scheduled Tasks 8.2

@covers ::executeTasks

File

tests/src/Unit/TaskRunnerTest.php, line 83

Class

TaskRunnerTest
@coversDefaultClass \Drupal\webform_scheduled_tasks\TaskRunner @group webform_scheduled_tasks

Namespace

Drupal\Tests\webform_scheduled_tasks\Unit

Code

public function testRetryScheduledTaskExceptionThrown() {
  $task = $this
    ->prophesize(TaskPluginInterface::class);
  $task
    ->executeTask(Argument::any(), Argument::any())
    ->willThrow(new RetryScheduledTaskException('Failed to do something.'));
  $scheduled_task = $this
    ->createTestScheduledTask($task);

  // When a retry exception is thrown, a fail will be registered but the task
  // date will be incremented and the task will not be halted.
  $scheduled_task
    ->registerFailedTask(Argument::any())
    ->shouldBeCalled();
  $scheduled_task
    ->incrementTaskRunDateByInterval()
    ->shouldBeCalled();
  $this->taskRunner
    ->executeTasks([
    $scheduled_task
      ->reveal(),
  ]);
}