You are here

public function ScheduleSuccessFailTest::testRegisteringStatusWithPlugins in Webform Scheduled Tasks 8.2

Test registering the status of a run with plugins.

File

tests/src/Kernel/ScheduleSuccessFailTest.php, line 52

Class

ScheduleSuccessFailTest
Test the schedule integration with plugins during success/fail.

Namespace

Drupal\Tests\webform_scheduled_tasks\Kernel

Code

public function testRegisteringStatusWithPlugins() {
  Webform::create([
    'id' => 'foo',
  ]);
  $scheduled_task = WebformScheduledTask::create([
    'id' => 'foo',
    'result_set_type' => 'test_result_set',
    'task_type' => 'test_task',
    'webform' => 'foo',
  ]);
  $scheduled_task
    ->registerSuccessfulTask();
  $this
    ->assertEquals([
    'Run test_result_set ::onSuccess',
    'Run test_task ::onSuccess',
  ], $this->messenger
    ->all()['status']);
  $this->messenger
    ->deleteAll();
  $scheduled_task
    ->registerFailedTask();
  $this
    ->assertEquals([
    'Run test_result_set ::onFailure',
    'Run test_task ::onFailure',
  ], $this->messenger
    ->all()['status']);
}