Skip to content
Snippets Groups Projects
Commit 3aecfda0 authored by Robin Appelman's avatar Robin Appelman
Browse files

Adjust backgroundjob test cases

parent 7948341a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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));
}
}
}
......@@ -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
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment