mirror of https://github.com/nextcloud/server.git
Add test for ParallelAwareJob
Signed-off-by: Marcel Klehr <mklehr@gmx.net>pull/39473/head
parent
f3bdcfd427
commit
449a731375
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 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;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use Test\BackgroundJob\JobTest;
|
||||
|
||||
class TestParallelAwareJob extends \OCP\BackgroundJob\Job {
|
||||
private $testCase;
|
||||
|
||||
/**
|
||||
* @var callable $callback
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* @param JobTest $testCase
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function __construct(ITimeFactory $time = null, $testCase = null, $callback = null) {
|
||||
parent::__construct($time ?? \OC::$server->get(ITimeFactory::class));
|
||||
$this->setAllowParallelRuns(false);
|
||||
$this->testCase = $testCase;
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function run($argument) {
|
||||
$this->testCase->markRun();
|
||||
$callback = $this->callback;
|
||||
$callback($argument);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue