diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2016-01-28 22:59:48 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2016-01-29 13:08:02 +0100 |
commit | 01cdc70f9c8fd98d2ea49bcfba9005f2797c815d (patch) | |
tree | b853e7991ab474b1519e54c30bfc1ed0e5a37953 /tests | |
parent | 24025f32f448d9bef1087bea01d771dd7e871996 (diff) | |
download | nextcloud-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.php | 4 | ||||
-rw-r--r-- | tests/lib/comments/manager.php | 57 |
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); + } + } |