Exemplo n.º 1
0
 /**
  * @dataProvider runDataProvider
  */
 public function testRun($expectedTimetable, $expectedExecutedTasks, $timetableBeforeTaskExecution, $configuredTasks)
 {
     $taskLoader = $this->getMock('Piwik\\Scheduler\\TaskLoader');
     $taskLoader->expects($this->atLeastOnce())->method('loadTasks')->willReturn($configuredTasks);
     // stub the piwik option object to control the returned option value
     self::stubPiwikOption(serialize($timetableBeforeTaskExecution));
     $scheduler = new Scheduler($taskLoader, new NullLogger());
     // execute tasks
     $executionResults = $scheduler->run();
     // assert methods are executed
     $executedTasks = array();
     foreach ($executionResults as $executionResult) {
         $executedTasks[] = $executionResult['task'];
         $this->assertNotEmpty($executionResult['output']);
     }
     $this->assertEquals($expectedExecutedTasks, $executedTasks);
     // assert the timetable is correctly updated
     $timetable = new Timetable();
     $this->assertEquals($expectedTimetable, $timetable->getTimetable());
     self::resetPiwikOption();
 }
Exemplo n.º 2
0
 /**
  * Will run all scheduled tasks due to run at this time.
  *
  * @return array
  * @hideExceptForSuperUser
  */
 public function runScheduledTasks()
 {
     Piwik::checkUserHasSuperUserAccess();
     return $this->scheduler->run();
 }