aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-04-20 15:29:47 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-04-23 12:36:12 +0200
commit5608b5077873d1d6b83b2a0c7c45b6a6b243a61c (patch)
treeff24613f73f5fb0c6a947e60d52a0c563fdadaa5 /tests/lib
parent94038e0673d38a0ddfcbda2d6ece8d0d145b0956 (diff)
downloadnextcloud-server-5608b5077873d1d6b83b2a0c7c45b6a6b243a61c.tar.gz
nextcloud-server-5608b5077873d1d6b83b2a0c7c45b6a6b243a61c.zip
Fix BackgroundJob tests
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/BackgroundJob/JobListTest.php13
-rw-r--r--tests/lib/BackgroundJob/JobTest.php18
2 files changed, 20 insertions, 11 deletions
diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php
index b370a233075..78565c11780 100644
--- a/tests/lib/BackgroundJob/JobListTest.php
+++ b/tests/lib/BackgroundJob/JobListTest.php
@@ -32,6 +32,7 @@ class JobListTest extends TestCase {
/** @var \OCP\AppFramework\Utility\ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
protected $timeFactory;
+ private bool $ran = false;
protected function setUp(): void {
parent::setUp();
@@ -247,7 +248,10 @@ class JobListTest extends TestCase {
public function testHasReservedJobs() {
$this->clearJobsList();
- $job = new TestJob();
+ $job = new TestJob($this->timeFactory, $this, function () {
+ $this->assertTrue($this->instance->hasReservedJob());
+ $this->assertTrue($this->instance->hasReservedJob(TestJob::class));
+ });
$this->instance->add($job);
$this->assertFalse($this->instance->hasReservedJob());
@@ -255,7 +259,10 @@ class JobListTest extends TestCase {
$job->start($this->instance);
- $this->assertTrue($this->instance->hasReservedJob());
- $this->assertTrue($this->instance->hasReservedJob(TestJob::class));
+ $this->assertTrue($this->ran);
+ }
+
+ public function markRun() {
+ $this->ran = true;
}
}
diff --git a/tests/lib/BackgroundJob/JobTest.php b/tests/lib/BackgroundJob/JobTest.php
index 37ced6e4757..b44324711b8 100644
--- a/tests/lib/BackgroundJob/JobTest.php
+++ b/tests/lib/BackgroundJob/JobTest.php
@@ -33,8 +33,7 @@ class JobTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$logger->expects($this->once())
- ->method('logException')
- ->with($e);
+ ->method('error');
$this->assertCount(1, $jobList->getAll());
$job->execute($jobList, $logger);
@@ -54,8 +53,7 @@ class JobTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$logger->expects($this->once())
- ->method('logException')
- ->with($this->isInstanceOf(\Throwable::class));
+ ->method('error');
$this->assertCount(1, $jobList->getAll());
$job->execute($jobList, $logger);
@@ -65,7 +63,8 @@ class JobTest extends \Test\TestCase {
public function testDisallowParallelRunsWithNoOtherJobs() {
$jobList = new DummyJobList();
- $job = new TestJob($this->timeFactory, $this);
+ $job = new TestJob($this->timeFactory, $this, function() {
+ });
$job->setAllowParallelRuns(false);
$jobList->add($job);
@@ -77,7 +76,8 @@ class JobTest extends \Test\TestCase {
public function testAllowParallelRunsWithNoOtherJobs() {
$jobList = new DummyJobList();
- $job = new TestJob($this->timeFactory, $this);
+ $job = new TestJob($this->timeFactory, $this, function() {
+ });
$job->setAllowParallelRuns(true);
$jobList->add($job);
@@ -89,7 +89,8 @@ class JobTest extends \Test\TestCase {
public function testAllowParallelRunsWithOtherJobs() {
$jobList = new DummyJobList();
- $job = new TestJob($this->timeFactory, $this);
+ $job = new TestJob($this->timeFactory, $this, function() {
+ });
$job->setAllowParallelRuns(true);
$jobList->add($job);
@@ -101,7 +102,8 @@ class JobTest extends \Test\TestCase {
public function testDisallowParallelRunsWithOtherJobs() {
$jobList = new DummyJobList();
- $job = new TestJob($this->timeFactory, $this);
+ $job = new TestJob($this->timeFactory, $this, function() {
+ });
$job->setAllowParallelRuns(false);
$jobList->add($job);