1
0

QueuedJobTest.php 900 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright (c) 2013 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. use OCP\BackgroundJob\QueuedJob;
  11. class TestQueuedJobNew extends QueuedJob {
  12. public bool $ran = false;
  13. public function run($argument) {
  14. $this->ran = true;
  15. }
  16. }
  17. class QueuedJobTest extends \Test\TestCase {
  18. private DummyJobList $jobList;
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->jobList = new DummyJobList();
  22. }
  23. public function testJobShouldBeRemovedNew() {
  24. $job = new TestQueuedJobNew(\OCP\Server::get(ITimeFactory::class));
  25. $job->setId(42);
  26. $this->jobList->add($job);
  27. $this->assertTrue($this->jobList->has($job, null));
  28. $job->start($this->jobList);
  29. $this->assertTrue($job->ran);
  30. }
  31. }