Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2020-01-31 18:04:04 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2020-01-31 18:04:04 +0300
commit018020108bef98b393bc0a4da11ca049ddc06234 (patch)
tree7f84d632b237aa9889c68db71977a49767f253a6 /tests
parent4765f5b3db6e8e3d2acae19a0c00f616729c1155 (diff)
Make sure to catch php errors during job execution
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
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;
}