TaskRunner example

/** * @internal * * @covers \Shopware\Core\Framework\MessageQueue\ScheduledTask\Scheduler\TaskRunner */
class TaskRunnerTest extends TestCase
{
    public function testNonExistingTask(): void
    {
        /** @var StaticEntityRepository<ScheduledTaskCollection> $scheduledTaskRepository */
        $scheduledTaskRepository = new StaticEntityRepository([new ScheduledTaskCollection()]);
        $taskRunner = new TaskRunner([]$scheduledTaskRepository);

        $this->expectException(MessageQueueException::class);
        $this->expectExceptionMessage('Cannot find scheduled task by name "non-existing-task"');
        $taskRunner->runSingleTask('non-existing-task', Context::createDefaultContext());
    }

    public function testRunTaskTriggersHandler(): void
    {
        $handler = new TestTaskHandler();
        $handler2 = new TestTask2Handler();
        $invalid = $this->createMock(StaticEntityRepository::class);
        
Home | Imprint | This part of the site doesn't use cookies.