nextcloud/tests/lib/BackgroundJob/TestJob.php

40 lines
800 B
PHP
Raw Permalink Normal View History

2014-02-12 07:52:13 -05:00
<?php
2014-02-12 07:52:13 -05: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 07:52:13 -05:00
*/
namespace Test\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\Job;
use OCP\Server;
class TestJob extends Job {
2014-02-12 07:52:13 -05:00
/**
* @var callable $callback
*/
private $callback;
/**
* @param JobTest $testCase
2014-02-12 07:52:13 -05:00
* @param callable $callback
*/
public function __construct(
?ITimeFactory $time = null,
private $testCase = null,
$callback = null,
) {
parent::__construct($time ?? Server::get(ITimeFactory::class));
2014-02-12 07:52:13 -05:00
$this->callback = $callback;
}
public function run($argument) {
$this->testCase->markRun();
$callback = $this->callback;
$callback($argument);
}
}