2929use OCA \Deck \Db \BoardMapper ;
3030use OCA \Deck \Db \Card ;
3131use OCA \Deck \Db \CardMapper ;
32+ use OCA \Deck \Db \Stack ;
33+ use OCA \Deck \Db \StackMapper ;
3234use OCA \Deck \InvalidAttachmentType ;
3335use OCA \Deck \Service \AttachmentService ;
3436use OCA \Deck \Service \IAttachmentService ;
@@ -48,6 +50,8 @@ class DeleteCronTest extends TestCase {
4850 private $ attachmentService ;
4951 /** @var AttachmentMapper|MockObject */
5052 private $ attachmentMapper ;
53+ /** @var StackMapper|MockObject */
54+ private $ stackMapper ;
5155 /** @var DeleteCron */
5256 protected $ deleteCron ;
5357
@@ -58,7 +62,8 @@ public function setUp(): void {
5862 $ this ->cardMapper = $ this ->createMock (CardMapper::class);
5963 $ this ->attachmentService = $ this ->createMock (AttachmentService::class);
6064 $ this ->attachmentMapper = $ this ->createMock (AttachmentMapper::class);
61- $ this ->deleteCron = new DeleteCron ($ this ->timeFactory , $ this ->boardMapper , $ this ->cardMapper , $ this ->attachmentService , $ this ->attachmentMapper );
65+ $ this ->stackMapper = $ this ->createMock (StackMapper::class);
66+ $ this ->deleteCron = new DeleteCron ($ this ->timeFactory , $ this ->boardMapper , $ this ->cardMapper , $ this ->attachmentService , $ this ->attachmentMapper , $ this ->stackMapper );
6267 }
6368
6469 protected function getBoard ($ id ) {
@@ -73,6 +78,12 @@ protected function getCard($id) {
7378 return $ card ;
7479 }
7580
81+ protected function getStack ($ id ) {
82+ $ stack = new Stack ();
83+ $ stack ->setId ($ id );
84+ return $ stack ;
85+ }
86+
7687 public function testDeleteCron () {
7788 $ boards = [
7889 $ this ->getBoard (1 ),
@@ -117,6 +128,21 @@ public function testDeleteCron() {
117128 $ this ->attachmentMapper ->expects ($ this ->once ())
118129 ->method ('delete ' )
119130 ->with ($ attachment );
131+
132+ $ stacks = [
133+ $ this ->getStack (100 ),
134+ $ this ->getStack (101 ),
135+ ];
136+ $ this ->stackMapper ->expects ($ this ->once ())
137+ ->method ('findToDelete ' )
138+ ->willReturn ($ stacks );
139+ $ this ->stackMapper ->expects ($ this ->exactly (count ($ stacks )))
140+ ->method ('delete ' )
141+ ->withConsecutive (
142+ [$ stacks [0 ]],
143+ [$ stacks [1 ]]
144+ );
145+
120146 $ this ->invokePrivate ($ this ->deleteCron , 'run ' , [null ]);
121147 }
122148
0 commit comments