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,13 @@ protected function getCard($id) {
7479 return $ card ;
7580 }
7681
82+ protected function getStack ($ id )
83+ {
84+ $ stack = new Stack ();
85+ $ stack ->setId ($ id );
86+ return $ stack ;
87+ }
88+
7789 public function testDeleteCron () {
7890 $ boards = [
7991 $ this ->getBoard (1 ),
@@ -118,6 +130,21 @@ public function testDeleteCron() {
118130 $ this ->attachmentMapper ->expects ($ this ->once ())
119131 ->method ('delete ' )
120132 ->with ($ attachment );
133+
134+ $ stacks = [
135+ $ this ->getStack (100 ),
136+ $ this ->getStack (101 ),
137+ ];
138+ $ this ->stackMapper ->expects ($ this ->once ())
139+ ->method ('findToDelete ' )
140+ ->willReturn ($ stacks );
141+ $ this ->stackMapper ->expects ($ this ->exactly (count ($ stacks )))
142+ ->method ('delete ' )
143+ ->withConsecutive (
144+ [$ stacks [0 ]],
145+ [$ stacks [1 ]]
146+ );
147+
121148 $ this ->invokePrivate ($ this ->deleteCron , 'run ' , [null ]);
122149 }
123150
0 commit comments