summaryrefslogtreecommitdiffstats
path: root/tests/lib/backgroundjob/queuedjob.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/backgroundjob/queuedjob.php')
-rw-r--r--tests/lib/backgroundjob/queuedjob.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/lib/backgroundjob/queuedjob.php b/tests/lib/backgroundjob/queuedjob.php
new file mode 100644
index 00000000000..1d373473cd7
--- /dev/null
+++ b/tests/lib/backgroundjob/queuedjob.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\BackgroundJob;
+
+class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
+ public function run($argument) {
+ throw new JobRun(); //throw an exception so we can detect if this function is called
+ }
+}
+
+class QueuedJob extends \PHPUnit_Framework_TestCase {
+ /**
+ * @var DummyJobList $jobList
+ */
+ private $jobList;
+ /**
+ * @var \OC\BackgroundJob\TimedJob $job
+ */
+ private $job;
+
+ public function setup() {
+ $this->jobList = new DummyJobList();
+ $this->job = new TestQueuedJob();
+ $this->jobList->add($this->job);
+ }
+
+ public function testJobShouldBeRemoved() {
+ try {
+ $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, null));
+ }
+ }
+}