ListScheduledTaskCommand example

$entity->setId('test');
        $entity->setName('TestTask.ID');
        $entity->setNextExecutionTime(new \DateTime());
        $entity->setRunInterval(100);
        $entity->setStatus(ScheduledTaskDefinition::STATUS_QUEUED);

        $taskRegistry = $this->createMock(TaskRegistry::class);
        $taskRegistry
            ->method('getAllTasks')
            ->willReturn(new ScheduledTaskCollection([$entity]));

        $command = new ListScheduledTaskCommand($taskRegistry);

        $tester = new CommandTester($command);
        $tester->execute([]);

        static::assertStringContainsString('Name', $tester->getDisplay());
        static::assertStringContainsString('Next execution', $tester->getDisplay());
        static::assertStringContainsString('Last execution', $tester->getDisplay());
        static::assertStringContainsString('Run interval', $tester->getDisplay());
        static::assertStringContainsString('Status', $tester->getDisplay());
        static::assertStringContainsString('TestTask.ID', $tester->getDisplay());
    }
}
Home | Imprint | This part of the site doesn't use cookies.