QueuedJobTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
  10. private $testCase;
  11. /**
  12. * @param QueuedJobTest $testCase
  13. */
  14. public function __construct($testCase) {
  15. $this->testCase = $testCase;
  16. }
  17. public function run($argument) {
  18. $this->testCase->markRun();
  19. }
  20. }
  21. class QueuedJobTest extends \Test\TestCase {
  22. /**
  23. * @var DummyJobList $jobList
  24. */
  25. private $jobList;
  26. /**
  27. * @var \OC\BackgroundJob\TimedJob $job
  28. */
  29. private $job;
  30. private $jobRun = false;
  31. public function markRun() {
  32. $this->jobRun = true;
  33. }
  34. protected function setup() {
  35. parent::setUp();
  36. $this->jobList = new DummyJobList();
  37. $this->job = new TestQueuedJob($this);
  38. $this->jobList->add($this->job);
  39. $this->jobRun = false;
  40. }
  41. public function testJobShouldBeRemoved() {
  42. $this->assertTrue($this->jobList->has($this->job, null));
  43. $this->job->execute($this->jobList);
  44. $this->assertTrue($this->jobRun);
  45. }
  46. }