summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-07-01 15:53:37 +0200
committerJoas Schilling <coding@schilljs.com>2022-07-01 15:59:29 +0200
commit198224bf7a18903fb9e55d621604befa788f542c (patch)
tree36ffbeb8900ec886eebdbdf8a188b297828591c4 /tests
parent6222b702db03d7bf08bd80c760fdaca3c0167db5 (diff)
downloadnextcloud-server-198224bf7a18903fb9e55d621604befa788f542c.tar.gz
nextcloud-server-198224bf7a18903fb9e55d621604befa788f542c.zip
Allow to expire comments of multiple objects with one call
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Comments/ManagerTest.php43
1 files changed, 40 insertions, 3 deletions
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index 7c6971476c7..ae91efb8498 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -703,7 +703,7 @@ class ManagerTest extends TestCase {
$this->assertTrue($wasSuccessful);
}
- public function testDeleteMessageExpiredAtObject(): void {
+ public function testDeleteCommentsExpiredAtObjectTypeAndId(): void {
$ids = [];
$ids[] = $this->addDatabaseEntry(0, 0, null, null, null, new \DateTime('+2 hours'));
$ids[] = $this->addDatabaseEntry(0, 0, null, null, null, new \DateTime('+2 hours'));
@@ -726,7 +726,7 @@ class ManagerTest extends TestCase {
$this->assertSame($comment->getObjectType(), 'files');
$this->assertSame($comment->getObjectId(), 'file64');
- $deleted = $manager->deleteMessageExpiredAtObject('files', 'file64');
+ $deleted = $manager->deleteCommentsExpiredAtObject('files', 'file64');
$this->assertTrue($deleted);
$deleted = 0;
@@ -744,7 +744,44 @@ class ManagerTest extends TestCase {
// actor info is gone from DB, but when database interaction is alright,
// we still expect to get true back
- $deleted = $manager->deleteMessageExpiredAtObject('files', 'file64');
+ $deleted = $manager->deleteCommentsExpiredAtObject('files', 'file64');
+ $this->assertFalse($deleted);
+ }
+
+ public function testDeleteCommentsExpiredAtObjectType(): void {
+ $ids = [];
+ $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file1', new \DateTime('-2 hours'));
+ $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file2', new \DateTime('-2 hours'));
+ $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file3', new \DateTime('-2 hours'));
+
+ $manager = new Manager(
+ $this->connection,
+ $this->createMock(LoggerInterface::class),
+ $this->createMock(IConfig::class),
+ Server::get(ITimeFactory::class),
+ new EmojiHelper($this->connection),
+ $this->createMock(IInitialStateService::class)
+ );
+
+ $deleted = $manager->deleteCommentsExpiredAtObject('files');
+ $this->assertTrue($deleted);
+
+ $deleted = 0;
+ $exists = 0;
+ foreach ($ids as $id) {
+ try {
+ $manager->get((string) $id);
+ $exists++;
+ } catch (NotFoundException $e) {
+ $deleted++;
+ }
+ }
+ $this->assertSame($exists, 0);
+ $this->assertSame($deleted, 3);
+
+ // actor info is gone from DB, but when database interaction is alright,
+ // we still expect to get true back
+ $deleted = $manager->deleteCommentsExpiredAtObject('files');
$this->assertFalse($deleted);
}