From 3aecfda0c052c1b7f7a4e3459f339a27298e32a7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 20 Apr 2013 23:51:58 +0200 Subject: [PATCH] Adjust backgroundjob test cases --- tests/lib/backgroundjob/dummyjoblist.php | 12 ++++++++---- tests/lib/backgroundjob/queuedjob.php | 6 +++--- tests/lib/backgroundjob/timedjob.php | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/lib/backgroundjob/dummyjoblist.php b/tests/lib/backgroundjob/dummyjoblist.php index c4ccfc22c9e..833607c15c2 100644 --- a/tests/lib/backgroundjob/dummyjoblist.php +++ b/tests/lib/backgroundjob/dummyjoblist.php @@ -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; } diff --git a/tests/lib/backgroundjob/queuedjob.php b/tests/lib/backgroundjob/queuedjob.php index 62d631a3ef0..1d373473cd7 100644 --- a/tests/lib/backgroundjob/queuedjob.php +++ b/tests/lib/backgroundjob/queuedjob.php @@ -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)); } } } diff --git a/tests/lib/backgroundjob/timedjob.php b/tests/lib/backgroundjob/timedjob.php index 4147b82cbbe..0af933afef8 100644 --- a/tests/lib/backgroundjob/timedjob.php +++ b/tests/lib/backgroundjob/timedjob.php @@ -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 } } -- 2.39.5