Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 2.66 KB

test.md

File metadata and controls

60 lines (43 loc) · 2.66 KB

Tests

This bundle provides a set of constraints built on top of the API to assert on task lifecycle.

Tasks

Constraint Description
TaskExecuted Assert on the executed task count
TaskFailed Assert on the failed task count
TaskQueued Assert on the queued task count
TaskScheduled Assert on the scheduled task count
TaskUnscheduled Assert on the unscheduled task count

Probe

Constraint Description
ProbeEnabled Assert on the probe state
ProbeExecutedTask Assert on the unscheduled task count
ProbeFailedTask Assert on the unscheduled task count
ProbeScheduledTask Assert on the unscheduled task count
ProbeState Assert against the current probe state

Scheduler

Constraint Description
SchedulerDueTask Assert on the due tasks count

Tests trait

A little bonus is the SchedulerAssertionTrait that can be used on tests that extend KernelTestCase:

<?php

declare(strict_types=1);

use SchedulerBundle\Test\SchedulerAssertionTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

final class FooTest extends KernelTestCase
{
    use SchedulerAssertionTrait;
    
    public function testFoo(): void
    {
        // TODO

        self::assertTaskExecutedCount(1);
    }
}

The complete list of assertions can be found in the trait.