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