Unit tests for missing service methods

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-18 13:23:53 +02:00
parent 7955a19149
commit 63ad39dd2d
3 changed files with 119 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ use OCA\Deck\Db\Attachment;
use OCA\Deck\Db\AttachmentMapper;
use OCA\Deck\Db\Board;
use OCA\Deck\Db\BoardMapper;
use OCA\Deck\InvalidAttachmentType;
use OCA\Deck\Service\AttachmentService;
use OCA\Deck\Service\IAttachmentService;
@@ -97,4 +98,24 @@ class DeleteCronTest extends \Test\TestCase {
->with($attachment);
$this->invokePrivate($this->deleteCron, 'run', [null]);
}
public function testDeleteCronInvalidAttachment() {
$boards = [];
$this->boardMapper->expects($this->once())
->method('findToDelete')
->willReturn($boards);
$attachment = new Attachment();
$attachment->setType('deck_file_invalid');
$this->attachmentMapper->expects($this->once())
->method('findToDelete')
->willReturn([$attachment]);
$this->attachmentService->expects($this->once())
->method('getService')
->will($this->throwException(new InvalidAttachmentType('deck_file_invalid')));
$this->attachmentMapper->expects($this->once())
->method('delete')
->with($attachment);
$this->invokePrivate($this->deleteCron, 'run', [null]);
}
}