mirror of
https://github.com/nextcloud/server.git
synced 2024-12-29 00:18:42 +00:00
1f7e2ba599
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
36 lines
814 B
PHP
36 lines
814 B
PHP
<?php
|
|
/**
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace Test\BackgroundJob;
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
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);
|
|
}
|
|
}
|