TestJob.php 814 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\BackgroundJob;
  8. use OCP\AppFramework\Utility\ITimeFactory;
  9. class TestJob extends \OCP\BackgroundJob\Job {
  10. private $testCase;
  11. /**
  12. * @var callable $callback
  13. */
  14. private $callback;
  15. /**
  16. * @param JobTest $testCase
  17. * @param callable $callback
  18. */
  19. public function __construct(?ITimeFactory $time = null, $testCase = null, $callback = null) {
  20. parent::__construct($time ?? \OCP\Server::get(ITimeFactory::class));
  21. $this->testCase = $testCase;
  22. $this->callback = $callback;
  23. }
  24. public function run($argument) {
  25. $this->testCase->markRun();
  26. $callback = $this->callback;
  27. $callback($argument);
  28. }
  29. }