Esempio n. 1
0
 protected function getAllSorted()
 {
     $jobs = $this->instance->getAll();
     usort($jobs, function (IJob $job1, IJob $job2) {
         return $job1->getId() - $job2->getId();
     });
     return $jobs;
 }
Esempio n. 2
0
 public function testSetLastRun()
 {
     $job = new TestJob();
     $this->instance->add($job);
     $jobs = $this->instance->getAll();
     $addedJob = $jobs[count($jobs) - 1];
     $timeStart = time();
     $this->instance->setLastRun($addedJob);
     $timeEnd = time();
     $addedJob = $this->instance->getById($addedJob->getId());
     $this->assertGreaterThanOrEqual($timeStart, $addedJob->getLastRun());
     $this->assertLessThanOrEqual($timeEnd, $addedJob->getLastRun());
     $this->instance->remove($job);
 }
Esempio n. 3
0
 public function testGetNextNonExisting()
 {
     $job = new TestJob();
     $this->instance->add($job, 1);
     $this->instance->add('\\OC\\Non\\Existing\\Class');
     $this->instance->add($job, 2);
     $jobs = $this->instance->getAll();
     $savedJob1 = $jobs[count($jobs) - 2];
     $savedJob2 = $jobs[count($jobs) - 1];
     $this->config->expects($this->any())->method('getAppValue')->with('backgroundjob', 'lastjob', 0)->will($this->returnValue($savedJob1->getId()));
     $this->instance->getNext();
     $nextJob = $this->instance->getNext();
     $this->assertEquals($savedJob2, $nextJob);
     $this->instance->remove($job, 1);
     $this->instance->remove($job, 2);
 }
 /**
  * @deprecated
  * Gets all queued tasks of a specific app
  * @param string $app app name
  * @return array with associative arrays
  */
 public static function queuedTaskWhereAppIs($app)
 {
     $jobList = new JobList();
     $allJobs = $jobList->getAll();
     $queuedJobs = array();
     foreach ($allJobs as $job) {
         if ($job instanceof QueuedLegacyJob) {
             $queuedJob = $job->getArgument();
             $queuedJob['id'] = $job->getId();
             if ($queuedJob['app'] === $app) {
                 $queuedJobs[] = $queuedJob;
             }
         }
     }
     return $queuedJobs;
 }