diff options
Diffstat (limited to 'tests/lib/BackgroundJob/TestJob.php')
-rw-r--r-- | tests/lib/BackgroundJob/TestJob.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/lib/BackgroundJob/TestJob.php b/tests/lib/BackgroundJob/TestJob.php new file mode 100644 index 00000000000..ac18530ac7f --- /dev/null +++ b/tests/lib/BackgroundJob/TestJob.php @@ -0,0 +1,39 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace Test\BackgroundJob; + +use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\Job; +use OCP\Server; + +class TestJob extends Job { + /** + * @var callable $callback + */ + private $callback; + + /** + * @param JobTest $testCase + * @param callable $callback + */ + public function __construct( + ?ITimeFactory $time = null, + private $testCase = null, + $callback = null, + ) { + parent::__construct($time ?? Server::get(ITimeFactory::class)); + $this->callback = $callback; + } + + public function run($argument) { + $this->testCase->markRun(); + $callback = $this->callback; + $callback($argument); + } +} |