0
0
mirror of https://github.com/nextcloud/server.git synced 2024-12-29 00:18:42 +00:00
nextcloud_server/tests/lib/BackgroundJob/TestParallelAwareJob.php
Andy Scherzinger 1f7e2ba599
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-13 17:41:36 +02:00

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);
}
}