2424use OCA \Mail \Service \Attachment \AttachmentStorage ;
2525use OCA \Mail \Service \Attachment \UploadedFile ;
2626use OCP \AppFramework \Db \DoesNotExistException ;
27+ use OCP \AppFramework \Utility \ITimeFactory ;
2728use OCP \Files \Folder ;
2829use OCP \Files \NotPermittedException ;
2930use OCP \Share \IAttributes ;
@@ -53,6 +54,9 @@ class AttachmentServiceTest extends TestCase {
5354 /** @var MockObject|LoggerInterface */
5455 private $ logger ;
5556
57+ /** @var ITimeFactory|MockObject */
58+ private $ timeFactory ;
59+
5660 protected function setUp (): void {
5761 parent ::setUp ();
5862
@@ -62,14 +66,17 @@ protected function setUp(): void {
6266 $ this ->messageMapper = $ this ->createMock (MessageMapper::class);
6367 $ this ->userFolder = $ this ->createMock (Folder::class);
6468 $ this ->logger = $ this ->createMock (LoggerInterface::class);
69+ $ this ->timeFactory = $ this ->createMock (ITimeFactory::class);
70+ $ this ->timeFactory ->method ('getTime ' )->willReturn (123456 );
6571
6672 $ this ->service = new AttachmentService (
6773 $ this ->userFolder ,
6874 $ this ->mapper ,
6975 $ this ->storage ,
7076 $ this ->mailManager ,
7177 $ this ->messageMapper ,
72- $ this ->logger
78+ $ this ->logger ,
79+ $ this ->timeFactory
7380 );
7481 }
7582
@@ -82,6 +89,7 @@ public function testAddFileWithUploadException() {
8289 $ attachment = LocalAttachment::fromParams ([
8390 'userId ' => $ userId ,
8491 'fileName ' => 'cat.jpg ' ,
92+ 'createdAt ' => 123456 ,
8593 ]);
8694 $ persistedAttachment = LocalAttachment::fromParams ([
8795 'id ' => 123 ,
@@ -113,7 +121,8 @@ public function testAddFile() {
113121 ->willReturn ('cat.jpg ' );
114122 $ attachment = LocalAttachment::fromParams ([
115123 'userId ' => $ userId ,
116- 'fileName ' => 'cat.jpg '
124+ 'fileName ' => 'cat.jpg ' ,
125+ 'createdAt ' => 123456
117126 ]);
118127 $ persistedAttachment = LocalAttachment::fromParams ([
119128 'id ' => 123 ,
@@ -138,6 +147,7 @@ public function testAddFileFromStringWithUploadException() {
138147 'userId ' => $ userId ,
139148 'fileName ' => 'cat.jpg ' ,
140149 'mimeType ' => 'image/jpg ' ,
150+ 'createdAt ' => 123456 ,
141151 ]);
142152 $ persistedAttachment = LocalAttachment::fromParams ([
143153 'id ' => 123 ,
@@ -168,6 +178,7 @@ public function testAddFileFromString() {
168178 'userId ' => $ userId ,
169179 'fileName ' => 'cat.jpg ' ,
170180 'mimeType ' => 'image/jpg ' ,
181+ 'createdAt ' => 123456 ,
171182 ]);
172183 $ persistedAttachment = LocalAttachment::fromParams ([
173184 'id ' => 123 ,
@@ -283,6 +294,7 @@ public function testHandleAttachmentsForwardedMessageAttachment(): void {
283294 'userId ' => $ userId ,
284295 'fileName ' => 'cat.jpg ' ,
285296 'mimeType ' => 'text/plain ' ,
297+ 'createdAt ' => 123456 ,
286298 ]);
287299 $ persistedAttachment = LocalAttachment::fromParams ([
288300 'id ' => 123 ,
@@ -334,6 +346,7 @@ public function testHandleAttachmentsForwardedAttachment(): void {
334346 'userId ' => $ userId ,
335347 'fileName ' => 'cat.jpg ' ,
336348 'mimeType ' => 'text/plain ' ,
349+ 'createdAt ' => 123456 ,
337350 ]);
338351 $ persistedAttachment = LocalAttachment::fromParams ([
339352 'id ' => 123 ,
@@ -443,6 +456,7 @@ public function testHandleAttachmentsCloudAttachment(): void {
443456 'userId ' => $ userId ,
444457 'fileName ' => 'cat.jpg ' ,
445458 'mimeType ' => 'text/plain ' ,
459+ 'createdAt ' => 123456 ,
446460 ]);
447461 $ persistedAttachment = LocalAttachment::fromParams ([
448462 'id ' => 123 ,
0 commit comments