2014-02-12 12:52:13 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2024-05-10 13:09:14 +00:00
|
|
|
* SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2014-02-12 12:52:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\BackgroundJob;
|
|
|
|
|
2023-04-20 11:18:28 +00:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
|
|
|
|
class TestJob extends \OCP\BackgroundJob\Job {
|
2014-02-12 12:52:13 +00:00
|
|
|
private $testCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var callable $callback
|
|
|
|
*/
|
|
|
|
private $callback;
|
|
|
|
|
|
|
|
/**
|
2016-05-20 13:38:20 +00:00
|
|
|
* @param JobTest $testCase
|
2014-02-12 12:52:13 +00:00
|
|
|
* @param callable $callback
|
|
|
|
*/
|
2024-03-28 15:13:19 +00:00
|
|
|
public function __construct(?ITimeFactory $time = null, $testCase = null, $callback = null) {
|
2024-02-08 10:52:40 +00:00
|
|
|
parent::__construct($time ?? \OCP\Server::get(ITimeFactory::class));
|
2014-02-12 12:52:13 +00:00
|
|
|
$this->testCase = $testCase;
|
|
|
|
$this->callback = $callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run($argument) {
|
|
|
|
$this->testCase->markRun();
|
|
|
|
$callback = $this->callback;
|
|
|
|
$callback($argument);
|
|
|
|
}
|
|
|
|
}
|