TestJob.php 822 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\BackgroundJob;
  9. use OCP\AppFramework\Utility\ITimeFactory;
  10. class TestJob extends \OCP\BackgroundJob\Job {
  11. private $testCase;
  12. /**
  13. * @var callable $callback
  14. */
  15. private $callback;
  16. /**
  17. * @param JobTest $testCase
  18. * @param callable $callback
  19. */
  20. public function __construct(ITimeFactory $time = null, $testCase = null, $callback = null) {
  21. parent::__construct($time ?? \OC::$server->get(ITimeFactory::class));
  22. $this->testCase = $testCase;
  23. $this->callback = $callback;
  24. }
  25. public function run($argument) {
  26. $this->testCase->markRun();
  27. $callback = $this->callback;
  28. $callback($argument);
  29. }
  30. }