public function testSetLastRun()
 {
     $job = new TestJob();
     $this->instance->add($job);
     $jobs = $this->getAllSorted();
     $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());
 }
Exemple #2
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->getAllSorted();
     $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);
 }
 /**
  * @param \OC\BackgroundJob\Job|string $job
  * @param mixed $argument
  */
 public static function registerJob($job, $argument = null)
 {
     $jobList = new JobList();
     $jobList->add($job, $argument);
 }