public function HaltedTasksHealthzTest::testHealthCheck in Webform Scheduled Tasks 8.2
Test the interval scheduling.
File
- tests/
src/ Kernel/ HaltedTasksHealthzTest.php, line 44
Class
- HaltedTasksHealthzTest
- Test the halted tasks healthz check.
Namespace
Drupal\Tests\webform_scheduled_tasks\KernelCode
public function testHealthCheck() {
$webform = Webform::create([
'id' => 'foo',
]);
$webform
->save();
$schedule = WebformScheduledTask::create([
'id' => 'foo',
'result_set_type' => 'all_submissions',
'task_type' => 'test_task',
'webform' => $webform
->id(),
]);
$schedule
->save();
/** @var \Drupal\healthz\HealthzPluginManager $check_manager */
$check_manager = \Drupal::service('plugin.manager.healthz');
$health_check = $check_manager
->createInstance('webform_scheduled_tasks_halted');
$this
->assertTrue($health_check
->check());
$schedule
->halt('Something broke!');
$this
->assertFalse($health_check
->check());
}