aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-02-03 09:54:26 +0100
committerGitHub <noreply@github.com>2020-02-03 09:54:26 +0100
commit1b33116e8f5bc1c2345f58672a068fdc643d2b58 (patch)
tree2605d2e15a01265c7afea4f757ad008191348ab7 /tests
parent846eb8ee1d2e19e935e9d8d77805c7b0d3329b35 (diff)
parent018020108bef98b393bc0a4da11ca049ddc06234 (diff)
downloadnextcloud-server-1b33116e8f5bc1c2345f58672a068fdc643d2b58.tar.gz
nextcloud-server-1b33116e8f5bc1c2345f58672a068fdc643d2b58.zip
Merge pull request #19241 from nextcloud/bug/noid/job-catch-throwable
Make sure to catch php errors during job execution
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/BackgroundJob/JobTest.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/BackgroundJob/JobTest.php b/tests/lib/BackgroundJob/JobTest.php
index 6e5474e597c..b4048aa1c22 100644
--- a/tests/lib/BackgroundJob/JobTest.php
+++ b/tests/lib/BackgroundJob/JobTest.php
@@ -39,6 +39,27 @@ class JobTest extends \Test\TestCase {
$this->assertCount(1, $jobList->getAll());
}
+ public function testRemoveAfterError() {
+ $jobList = new DummyJobList();
+ $job = new TestJob($this, function () {
+ $test = null;
+ $test->someMethod();
+ });
+ $jobList->add($job);
+
+ $logger = $this->getMockBuilder(ILogger::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $logger->expects($this->once())
+ ->method('logException')
+ ->with($this->isInstanceOf(\Throwable::class));
+
+ $this->assertCount(1, $jobList->getAll());
+ $job->execute($jobList, $logger);
+ $this->assertTrue($this->run);
+ $this->assertCount(1, $jobList->getAll());
+ }
+
public function markRun() {
$this->run = true;
}