3030use OCA \Deck \Db \BoardMapper ;
3131use OCA \Deck \Db \Card ;
3232use OCA \Deck \Db \CardMapper ;
33+ use OCA \Deck \Db \Stack ;
34+ use OCA \Deck \Db \StackMapper ;
3335use OCA \Deck \InvalidAttachmentType ;
3436use OCA \Deck \Service \AttachmentService ;
3537use OCA \Deck \Service \IAttachmentService ;
@@ -49,6 +51,8 @@ class DeleteCronTest extends TestCase {
4951 private $ attachmentService ;
5052 /** @var AttachmentMapper|MockObject */
5153 private $ attachmentMapper ;
54+ /** @var StackMapper|MockObject */
55+ private $ stackMapper ;
5256 /** @var DeleteCron */
5357 protected $ deleteCron ;
5458
@@ -59,7 +63,8 @@ public function setUp(): void {
5963 $ this ->cardMapper = $ this ->createMock (CardMapper::class);
6064 $ this ->attachmentService = $ this ->createMock (AttachmentService::class);
6165 $ this ->attachmentMapper = $ this ->createMock (AttachmentMapper::class);
62- $ this ->deleteCron = new DeleteCron ($ this ->timeFactory , $ this ->boardMapper , $ this ->cardMapper , $ this ->attachmentService , $ this ->attachmentMapper );
66+ $ this ->stackMapper = $ this ->createMock (StackMapper::class);
67+ $ this ->deleteCron = new DeleteCron ($ this ->timeFactory , $ this ->boardMapper , $ this ->cardMapper , $ this ->attachmentService , $ this ->attachmentMapper , $ this ->stackMapper );
6368 }
6469
6570 protected function getBoard ($ id ) {
@@ -74,6 +79,12 @@ protected function getCard($id) {
7479 return $ card ;
7580 }
7681
82+ protected function getStack ($ id ) {
83+ $ stack = new Stack ();
84+ $ stack ->setId ($ id );
85+ return $ stack ;
86+ }
87+
7788 public function testDeleteCron () {
7889 $ boards = [
7990 $ this ->getBoard (1 ),
@@ -118,6 +129,21 @@ public function testDeleteCron() {
118129 $ this ->attachmentMapper ->expects ($ this ->once ())
119130 ->method ('delete ' )
120131 ->with ($ attachment );
132+
133+ $ stacks = [
134+ $ this ->getStack (100 ),
135+ $ this ->getStack (101 ),
136+ ];
137+ $ this ->stackMapper ->expects ($ this ->once ())
138+ ->method ('findToDelete ' )
139+ ->willReturn ($ stacks );
140+ $ this ->stackMapper ->expects ($ this ->exactly (count ($ stacks )))
141+ ->method ('delete ' )
142+ ->withConsecutive (
143+ [$ stacks [0 ]],
144+ [$ stacks [1 ]]
145+ );
146+
121147 $ this ->invokePrivate ($ this ->deleteCron , 'run ' , [null ]);
122148 }
123149
0 commit comments