diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-01-21 14:09:15 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-01-21 14:22:46 +0100 |
commit | 94a763a08450189d36791f9a8281e0c586927405 (patch) | |
tree | 058611449d8aa35eeb2271bc5e1abab175a7ab3a /apps/dav/tests/unit | |
parent | 5639e41cb066eba2636dadd283365d6f5e9e70b3 (diff) | |
download | nextcloud-server-94a763a08450189d36791f9a8281e0c586927405.tar.gz nextcloud-server-94a763a08450189d36791f9a8281e0c586927405.zip |
Inject user session to check for admin in system tags DAV handlers
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/systemtag/systemtagsbyidcollection.php | 19 | ||||
-rw-r--r-- | apps/dav/tests/unit/systemtag/systemtagsobjecttypecollection.php | 19 |
2 files changed, 35 insertions, 3 deletions
diff --git a/apps/dav/tests/unit/systemtag/systemtagsbyidcollection.php b/apps/dav/tests/unit/systemtag/systemtagsbyidcollection.php index cba943545af..a2bf571ab68 100644 --- a/apps/dav/tests/unit/systemtag/systemtagsbyidcollection.php +++ b/apps/dav/tests/unit/systemtag/systemtagsbyidcollection.php @@ -39,7 +39,24 @@ class SystemTagsByIdCollection extends \Test\TestCase { } public function getNode($isAdmin = true) { - return new \OCA\DAV\SystemTag\SystemTagsByIdCollection($isAdmin, $this->tagManager); + $user = $this->getMock('\OCP\IUser'); + $user->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('testuser')); + $userSession = $this->getMock('\OCP\IUserSession'); + $userSession->expects($this->any()) + ->method('getUser') + ->will($this->returnValue($user)); + $groupManager = $this->getMock('\OCP\IGroupManager'); + $groupManager->expects($this->any()) + ->method('isAdmin') + ->with('testuser') + ->will($this->returnValue($isAdmin)); + return new \OCA\DAV\SystemTag\SystemTagsByIdCollection( + $this->tagManager, + $userSession, + $groupManager + ); } public function adminFlagProvider() { diff --git a/apps/dav/tests/unit/systemtag/systemtagsobjecttypecollection.php b/apps/dav/tests/unit/systemtag/systemtagsobjecttypecollection.php index 2d343f4790a..e6d94803cc0 100644 --- a/apps/dav/tests/unit/systemtag/systemtagsobjecttypecollection.php +++ b/apps/dav/tests/unit/systemtag/systemtagsobjecttypecollection.php @@ -44,11 +44,26 @@ class SystemTagsObjectTypeCollection extends \Test\TestCase { $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager'); $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper'); + $user = $this->getMock('\OCP\IUser'); + $user->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('testuser')); + $userSession = $this->getMock('\OCP\IUserSession'); + $userSession->expects($this->any()) + ->method('getUser') + ->will($this->returnValue($user)); + $groupManager = $this->getMock('\OCP\IGroupManager'); + $groupManager->expects($this->any()) + ->method('isAdmin') + ->with('testuser') + ->will($this->returnValue(true)); + $this->node = new \OCA\DAV\SystemTag\SystemTagsObjectTypeCollection( 'files', - true, $this->tagManager, - $this->tagMapper + $this->tagMapper, + $userSession, + $groupManager ); } |