/**
  * See {@link Piwik\ScheduledTime::getRescheduledTime()}.
  */
 public function getRescheduledTime()
 {
     $nextScheduledTime = parent::getRescheduledTime();
     // if a geoip database is out of date, run the updater as soon as possible
     if ($this->isAtLeastOneGeoIpDbOutOfDate($nextScheduledTime)) {
         return time();
     }
     return $nextScheduledTime;
 }
예제 #2
0
 /**
  * @group Core
  *
  * Dataprovider for testRunTasks
  */
 public function testRunTasksTestCases()
 {
     $systemTime = time();
     $dailySchedule = $this->getMock('\\Piwik\\ScheduledTime\\Daily', array('getTime'));
     $dailySchedule->expects($this->any())->method('getTime')->will($this->returnValue($systemTime));
     $scheduledTaskOne = new ScheduledTask($this, 'scheduledTaskOne', null, $dailySchedule);
     $scheduledTaskTwo = new ScheduledTask($this, 'scheduledTaskTwo', 1, $dailySchedule);
     $scheduledTaskThree = new ScheduledTask($this, 'scheduledTaskThree', null, $dailySchedule);
     $caseOneExpectedTable = array('TaskSchedulerTest.scheduledTaskOne' => $scheduledTaskOne->getRescheduledTime(), 'TaskSchedulerTest.scheduledTaskTwo_1' => $systemTime + 60000, 'TaskSchedulerTest.scheduledTaskThree' => $scheduledTaskThree->getRescheduledTime());
     $caseTwoTimetableBeforeExecution = $caseOneExpectedTable;
     $caseTwoTimetableBeforeExecution['TaskSchedulerTest.scheduledTaskThree'] = $systemTime;
     // simulate elapsed time between case 1 and 2
     return array(array($caseOneExpectedTable, array('TaskSchedulerTest.scheduledTaskOne'), array('TaskSchedulerTest.scheduledTaskOne' => $systemTime, 'TaskSchedulerTest.scheduledTaskTwo_1' => $systemTime + 60000), array($scheduledTaskOne, $scheduledTaskTwo, $scheduledTaskThree)), array(array('TaskSchedulerTest.scheduledTaskOne' => $scheduledTaskOne->getRescheduledTime(), 'TaskSchedulerTest.scheduledTaskThree' => $scheduledTaskThree->getRescheduledTime()), array('TaskSchedulerTest.scheduledTaskThree'), $caseTwoTimetableBeforeExecution, array($scheduledTaskOne, $scheduledTaskThree)));
 }
예제 #3
0
 /**
  * Executes the given taks
  *
  * @param ScheduledTask $task
  * @return string
  */
 private static function executeTask($task)
 {
     try {
         $timer = new Timer();
         call_user_func(array($task->getObjectInstance(), $task->getMethodName()), $task->getMethodParameter());
         $message = $timer->__toString();
     } catch (Exception $e) {
         $message = 'ERROR: ' . $e->getMessage();
     }
     return $message;
 }
예제 #4
0
 /**
  * @group Core
  *
  * @dataProvider getTaskNameTestCases
  */
 public function testGetTaskName($expectedTaskName, $className, $methodName, $methodParameter)
 {
     $this->assertEquals($expectedTaskName, ScheduledTask::getTaskName($className, $methodName, $methodParameter));
 }