Пример #1
0
 /**
  * Test of oat\oatbox\task\TaskRunner::run()
  */
 public function testRun()
 {
     $taskRunner = new TaskRunner();
     $task = $this->getTask();
     $report = $taskRunner->run($task);
     $this->assertEquals([], $report->getErrors());
 }
Пример #2
0
 public function __invoke($params)
 {
     $tasksRun = 0;
     $queue = $this->getServiceManager()->get(Queue::CONFIG_ID);
     $runner = new TaskRunner();
     $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS);
     foreach ($queue as $task) {
         $subReport = $runner->run($task);
         $tasksRun++;
         $report->add($subReport);
     }
     $report->setMessage(__('Successfully ran %s tasks:', $tasksRun));
     return $report;
 }
Пример #3
0
 public function __invoke($params)
 {
     $statistics = array();
     $queue = $this->getServiceManager()->get(Queue::CONFIG_ID);
     $runner = new TaskRunner();
     $report = new Report(Report::TYPE_SUCCESS);
     foreach ($queue as $task) {
         $subReport = $runner->run($task);
         $statistics[$subReport->getType()] = isset($statistics[$subReport->getType()]) ? $statistics[$subReport->getType()] + 1 : 1;
         $report->add($subReport);
     }
     if (empty($statistics)) {
         $report = new Report(Report::TYPE_INFO, __('No tasks to run'));
     } else {
         if (isset($statistics[Report::TYPE_ERROR]) || isset($statistics[Report::TYPE_WARNING])) {
             $report->setType(Report::TYPE_WARNING);
         }
         $report->setMessage(__('Ran %s task(s):', array_sum($statistics)));
     }
     return $report;
 }