diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-22 09:55:29 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-22 10:14:14 +0100 |
commit | fe08b5e9d902c9dc2891c59cf7e8d3bcb2700150 (patch) | |
tree | 0238b7705748bd4d7e7bad4d9cb384cba1fa4103 /tests | |
parent | 8a8209796d4577644228121edc2231ae027217c7 (diff) | |
download | nextcloud-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.php | 26 |
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 */ |