nextcloud/tests/lib/backgroundjob/queuedjob.php

43 lines
1.0 KiB
PHP
Raw Normal View History

2013-04-21 01:27:46 +04:00
<?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 {
2013-04-21 01:51:58 +04:00
public function run($argument) {
2013-04-21 01:27:46 +04:00
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 {
2013-04-21 01:51:58 +04:00
$this->assertTrue($this->jobList->has($this->job, null));
2013-04-21 01:27:46 +04:00
$this->job->execute($this->jobList);
$this->fail("job should have been run");
} catch (JobRun $e) {
2013-04-21 01:51:58 +04:00
$this->assertFalse($this->jobList->has($this->job, null));
2013-04-21 01:27:46 +04:00
}
}
}