From 018020108bef98b393bc0a4da11ca049ddc06234 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 31 Jan 2020 16:04:04 +0100 Subject: Make sure to catch php errors during job execution Signed-off-by: Daniel Kesselberg --- tests/lib/BackgroundJob/JobTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') 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; } -- cgit v1.2.3