You are here

public function TaskRunnerTest::testHaltScheduledTaskExceptionThrown in Webform Scheduled Tasks 8.2

@covers ::executeTasks @dataProvider haltScheduledTaskExceptionThrownTestCases

File

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

Class

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

Namespace

Drupal\Tests\webform_scheduled_tasks\Unit

Code

public function testHaltScheduledTaskExceptionThrown($exception) {
  $task = $this
    ->prophesize(TaskPluginInterface::class);
  $task
    ->executeTask(Argument::any(), Argument::any())
    ->willThrow($exception);
  $scheduled_task = $this
    ->createTestScheduledTask($task);

  // When a halt schedule exception is thrown, the task will be halted and a
  // fail will be registered.
  $scheduled_task
    ->registerFailedTask($exception)
    ->shouldBeCalled();
  $scheduled_task
    ->halt('An error was encountered when running the task: Failed to do something.')
    ->shouldBeCalled();
  $this->taskRunner
    ->executeTasks([
    $scheduled_task
      ->reveal(),
  ]);
}