summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-01-28 22:59:48 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-01-29 13:08:02 +0100
commit01cdc70f9c8fd98d2ea49bcfba9005f2797c815d (patch)
treeb853e7991ab474b1519e54c30bfc1ed0e5a37953 /tests
parent24025f32f448d9bef1087bea01d771dd7e871996 (diff)
downloadnextcloud-server-01cdc70f9c8fd98d2ea49bcfba9005f2797c815d.tar.gz
nextcloud-server-01cdc70f9c8fd98d2ea49bcfba9005f2797c815d.zip
introduce comments read marke tables, comes with user cleanup after deletion
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/comments/fakemanager.php4
-rw-r--r--tests/lib/comments/manager.php57
2 files changed, 59 insertions, 2 deletions
diff --git a/tests/lib/comments/fakemanager.php b/tests/lib/comments/fakemanager.php
index 8e513cb301a..7186529e718 100644
--- a/tests/lib/comments/fakemanager.php
+++ b/tests/lib/comments/fakemanager.php
@@ -34,4 +34,8 @@ class FakeManager implements \OCP\Comments\ICommentsManager {
public function setReadMark($objectType, $objectId, \DateTime $dateTime, \OCP\IUser $user) {}
public function getReadMark($objectType, $objectId, \OCP\IUser $user) {}
+
+ public function deleteReadMarksFromUser(\OCP\IUser $user) {}
+
+ public function deleteReadMarksOnObject($objectType, $objectId) {}
}
diff --git a/tests/lib/comments/manager.php b/tests/lib/comments/manager.php
index 2578fcc5189..a71f78f2818 100644
--- a/tests/lib/comments/manager.php
+++ b/tests/lib/comments/manager.php
@@ -570,11 +570,64 @@ class Test_Comments_Manager extends TestCase
$dateTimeSet = new \DateTime();
$manager = $this->getManager();
- $manager->setReadMark('files', '36', $dateTimeSet, $user);
+ $manager->setReadMark('robot', '36', $dateTimeSet, $user);
- $dateTimeGet = $manager->getReadMark('files', '36', $user);
+ $dateTimeGet = $manager->getReadMark('robot', '36', $user);
$this->assertEquals($dateTimeGet, $dateTimeSet);
}
+ public function testSetMarkReadUpdate() {
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('alice'));
+
+ $dateTimeSet = new \DateTime('yesterday');
+
+ $manager = $this->getManager();
+ $manager->setReadMark('robot', '36', $dateTimeSet, $user);
+
+ $dateTimeSet = new \DateTime('today');
+ $manager->setReadMark('robot', '36', $dateTimeSet, $user);
+
+ $dateTimeGet = $manager->getReadMark('robot', '36', $user);
+
+ $this->assertEquals($dateTimeGet, $dateTimeSet);
+ }
+
+ public function testReadMarkDeleteUser() {
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('alice'));
+
+ $dateTimeSet = new \DateTime();
+
+ $manager = $this->getManager();
+ $manager->setReadMark('robot', '36', $dateTimeSet, $user);
+
+ $manager->deleteReadMarksFromUser($user);
+ $dateTimeGet = $manager->getReadMark('robot', '36', $user);
+
+ $this->assertNull($dateTimeGet);
+ }
+
+ public function testReadMarkDeleteObject() {
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('alice'));
+
+ $dateTimeSet = new \DateTime();
+
+ $manager = $this->getManager();
+ $manager->setReadMark('robot', '36', $dateTimeSet, $user);
+
+ $manager->deleteReadMarksOnObject('robot', '36');
+ $dateTimeGet = $manager->getReadMark('robot', '36', $user);
+
+ $this->assertNull($dateTimeGet);
+ }
+
}