Adjust backgroundjob test cases

This commit is contained in:
Robin Appelman 2013-04-20 23:51:58 +02:00
parent 7948341a86
commit 3aecfda0c0
3 changed files with 12 additions and 8 deletions

View File

@ -26,17 +26,20 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
/**
* @param \OC\BackgroundJob\Job|string $job
* @param mixed $argument
*/
public function add($job) {
if (!$this->has($job)) {
public function add($job, $argument = null) {
$job->setArgument($argument);
if (!$this->has($job, null)) {
$this->jobs[] = $job;
}
}
/**
* @param \OC\BackgroundJob\Job|string $job
* @param mixed $argument
*/
public function remove($job) {
public function remove($job, $argument = null) {
$index = array_search($job, $this->jobs);
if ($index !== false) {
unset($this->jobs[$index]);
@ -47,9 +50,10 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
* check if a job is in the list
*
* @param $job
* @param mixed $argument
* @return bool
*/
public function has($job) {
public function has($job, $argument) {
return array_search($job, $this->jobs) !== false;
}

View File

@ -9,7 +9,7 @@
namespace Test\BackgroundJob;
class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
public function run() {
public function run($argument) {
throw new JobRun(); //throw an exception so we can detect if this function is called
}
}
@ -32,11 +32,11 @@ class QueuedJob extends \PHPUnit_Framework_TestCase {
public function testJobShouldBeRemoved() {
try {
$this->assertTrue($this->jobList->has($this->job));
$this->assertTrue($this->jobList->has($this->job, null));
$this->job->execute($this->jobList);
$this->fail("job should have been run");
} catch (JobRun $e) {
$this->assertFalse($this->jobList->has($this->job));
$this->assertFalse($this->jobList->has($this->job, null));
}
}
}

View File

@ -13,7 +13,7 @@ class TestTimedJob extends \OC\BackgroundJob\TimedJob {
$this->setInterval(10);
}
public function run() {
public function run($argument) {
throw new JobRun(); //throw an exception so we can detect if this function is called
}
}