summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-22 09:55:29 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-02-22 10:14:14 +0100
commitfe08b5e9d902c9dc2891c59cf7e8d3bcb2700150 (patch)
tree0238b7705748bd4d7e7bad4d9cb384cba1fa4103 /tests
parent8a8209796d4577644228121edc2231ae027217c7 (diff)
downloadnextcloud-server-fe08b5e9d902c9dc2891c59cf7e8d3bcb2700150.tar.gz
nextcloud-server-fe08b5e9d902c9dc2891c59cf7e8d3bcb2700150.zip
We should check for exceptions when trying to get the avatar
Fixes #22550 * Updated phpdoc of avatatmanager * Add unit test
Diffstat (limited to 'tests')
-rw-r--r--tests/settings/controller/userscontrollertest.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index 947540fa67b..6f07f34ba8d 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -1696,6 +1696,32 @@ class UsersControllerTest extends \Test\TestCase {
$this->assertEquals($expectedResult, $result);
}
+ public function testNoAvatar() {
+ $this->container['IsAdmin'] = true;
+
+ list($user, $expectedResult) = $this->mockUser();
+
+ $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $subadmin->expects($this->once())
+ ->method('getSubAdminsGroups')
+ ->with($user)
+ ->will($this->returnValue([]));
+ $this->container['GroupManager']
+ ->expects($this->any())
+ ->method('getSubAdmin')
+ ->will($this->returnValue($subadmin));
+
+ $this->container['OCP\\IAvatarManager']
+ ->method('getAvatar')
+ ->will($this->throwException(new \OCP\Files\NotFoundException()));
+ $expectedResult['isAvatarAvailable'] = false;
+
+ $result = self::invokePrivate($this->container['UsersController'], 'formatUserForIndex', [$user]);
+ $this->assertEquals($expectedResult, $result);
+ }
+
/**
* @return array
*/