From 94397dedb16b815a62c6883b872efabec94f2252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 12 Jun 2018 17:36:25 +0200 Subject: [PATCH] Fix delete cron test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/unit/Cron/DeleteCronTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/Cron/DeleteCronTest.php b/tests/unit/Cron/DeleteCronTest.php index ce0ea796c..bee1662e4 100644 --- a/tests/unit/Cron/DeleteCronTest.php +++ b/tests/unit/Cron/DeleteCronTest.php @@ -23,10 +23,12 @@ namespace OCA\Deck\Cron; +use OCA\Deck\Db\Attachment; use OCA\Deck\Db\AttachmentMapper; use OCA\Deck\Db\Board; use OCA\Deck\Db\BoardMapper; use OCA\Deck\Service\AttachmentService; +use OCA\Deck\Service\IAttachmentService; class DeleteCronTest extends \Test\TestCase { @@ -75,6 +77,24 @@ class DeleteCronTest extends \Test\TestCase { $this->boardMapper->expects($this->at(4)) ->method('delete') ->with($boards[3]); + + $attachment = new Attachment(); + $attachment->setType('deck_file'); + $this->attachmentMapper->expects($this->once()) + ->method('findToDelete') + ->willReturn([ + $attachment + ]); + $service = $this->createMock(IAttachmentService::class); + $service->expects($this->once()) + ->method('delete') + ->with($attachment); + $this->attachmentService->expects($this->once()) + ->method('getService') + ->willReturn($service); + $this->attachmentMapper->expects($this->once()) + ->method('delete') + ->with($attachment); $this->invokePrivate($this->deleteCron, 'run', [null]); } } \ No newline at end of file