mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 16:39:59 -04:00
test: update DummyJobList
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
b76f4fb2ea
commit
b724b111cc
2 changed files with 19 additions and 5 deletions
|
|
@ -70,7 +70,7 @@ interface IJobList {
|
|||
* Remove a job from the list by id
|
||||
*
|
||||
* @param int $id
|
||||
* @since 30.0.0
|
||||
* @since 27.1.12
|
||||
*/
|
||||
public function removeById(int $id): void;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
|
|||
private array $reserved = [];
|
||||
|
||||
private int $last = 0;
|
||||
private int $lastId = 0;
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
|
@ -41,6 +42,8 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
|
|||
$job = \OCP\Server::get($job);
|
||||
}
|
||||
$job->setArgument($argument);
|
||||
$job->setId($this->lastId);
|
||||
$this->lastId++;
|
||||
if (!$this->has($job, null)) {
|
||||
$this->jobs[] = $job;
|
||||
}
|
||||
|
|
@ -51,9 +54,20 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
|
|||
* @param mixed $argument
|
||||
*/
|
||||
public function remove($job, $argument = null): void {
|
||||
$index = array_search($job, $this->jobs);
|
||||
if ($index !== false) {
|
||||
unset($this->jobs[$index]);
|
||||
foreach ($this->jobs as $index => $listJob) {
|
||||
if (get_class($job) === get_class($listJob) && $job->getArgument() == $listJob->getArgument()) {
|
||||
unset($this->jobs[$index]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeById(int $id): void {
|
||||
foreach ($this->jobs as $index => $listJob) {
|
||||
if ($listJob->getId() === $id) {
|
||||
unset($this->jobs[$index]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +137,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
|
|||
}
|
||||
}
|
||||
|
||||
public function getById(int $id): IJob {
|
||||
public function getById(int $id): ?IJob {
|
||||
foreach ($this->jobs as $job) {
|
||||
if ($job->getId() === $id) {
|
||||
return $job;
|
||||
|
|
|
|||
Loading…
Reference in a new issue