-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20954 from owncloud/settings_user_only_load_avata…
…r_if_available Settings user only load avatar if available
- Loading branch information
Showing
4 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,30 @@ protected function setUp() { | |
->disableOriginalConstructor()->getMock(); | ||
$this->container['OCP\\App\\IAppManager'] = $this->getMockBuilder('OCP\\App\\IAppManager') | ||
->disableOriginalConstructor()->getMock(); | ||
|
||
|
||
/* | ||
* Set default avtar behaviour for whole testsuite | ||
*/ | ||
$this->container['OCP\\IAvatarManager'] = $this->getMock('OCP\IAvatarManager'); | ||
|
||
$avatarExists = $this->getMock('OCP\IAvatar'); | ||
$avatarExists->method('exists')->willReturn(true); | ||
$avatarNotExists = $this->getMock('OCP\IAvatar'); | ||
$avatarNotExists->method('exists')->willReturn(false); | ||
$this->container['OCP\\IAvatarManager'] | ||
->method('getAvatar') | ||
->will($this->returnValueMap([ | ||
['foo', $avatarExists], | ||
['bar', $avatarExists], | ||
['admin', $avatarNotExists], | ||
])); | ||
|
||
$this->container['Config'] | ||
->method('getSystemValue') | ||
->with('enable_avatars', true) | ||
->willReturn(true); | ||
|
||
} | ||
|
||
public function testIndexAdmin() { | ||
|
@@ -62,7 +86,7 @@ public function testIndexAdmin() { | |
$foo = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$foo | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('foo')); | ||
$foo | ||
|
@@ -86,7 +110,7 @@ public function testIndexAdmin() { | |
$admin = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$admin | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('admin')); | ||
$admin | ||
|
@@ -112,7 +136,7 @@ public function testIndexAdmin() { | |
$bar = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$bar | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('bar')); | ||
$bar | ||
|
@@ -188,7 +212,6 @@ public function testIndexAdmin() { | |
->method('getSubAdmin') | ||
->will($this->returnValue($subadmin)); | ||
|
||
|
||
$expectedResponse = new DataResponse( | ||
array( | ||
0 => array( | ||
|
@@ -202,6 +225,7 @@ public function testIndexAdmin() { | |
'backend' => 'OC_User_Database', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
1 => array( | ||
'name' => 'admin', | ||
|
@@ -214,6 +238,7 @@ public function testIndexAdmin() { | |
'backend' => '\Test\Util\User\Dummy', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => false, | ||
), | ||
2 => array( | ||
'name' => 'bar', | ||
|
@@ -226,6 +251,7 @@ public function testIndexAdmin() { | |
'backend' => '\Test\Util\User\Dummy', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
) | ||
); | ||
|
@@ -246,7 +272,7 @@ public function testIndexSubAdmin() { | |
$foo = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$foo | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('foo')); | ||
$foo | ||
|
@@ -270,7 +296,7 @@ public function testIndexSubAdmin() { | |
$admin = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$admin | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('admin')); | ||
$admin | ||
|
@@ -296,7 +322,7 @@ public function testIndexSubAdmin() { | |
$bar = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$bar | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('bar')); | ||
$bar | ||
|
@@ -401,6 +427,7 @@ public function testIndexSubAdmin() { | |
'backend' => '\Test\Util\User\Dummy', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
], | ||
1=> [ | ||
'name' => 'foo', | ||
|
@@ -413,6 +440,7 @@ public function testIndexSubAdmin() { | |
'backend' => 'OC_User_Database', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
], | ||
2 => [ | ||
'name' => 'admin', | ||
|
@@ -425,6 +453,7 @@ public function testIndexSubAdmin() { | |
'backend' => '\Test\Util\User\Dummy', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => false, | ||
], | ||
] | ||
); | ||
|
@@ -443,7 +472,7 @@ public function testIndexWithSearch() { | |
$foo = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$foo | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('foo')); | ||
$foo | ||
|
@@ -467,7 +496,7 @@ public function testIndexWithSearch() { | |
$admin = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$admin | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('admin')); | ||
$admin | ||
|
@@ -493,7 +522,7 @@ public function testIndexWithSearch() { | |
$bar = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$bar | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('bar')); | ||
$bar | ||
|
@@ -553,6 +582,7 @@ public function testIndexWithSearch() { | |
'backend' => 'OC_User_Database', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
1 => array( | ||
'name' => 'admin', | ||
|
@@ -565,6 +595,7 @@ public function testIndexWithSearch() { | |
'backend' => '\Test\Util\User\Dummy', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => false, | ||
), | ||
2 => array( | ||
'name' => 'bar', | ||
|
@@ -577,6 +608,7 @@ public function testIndexWithSearch() { | |
'backend' => '\Test\Util\User\Dummy', | ||
'email' => '[email protected]', | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
) | ||
); | ||
|
@@ -590,7 +622,7 @@ public function testIndexWithBackend() { | |
$user = $this->getMockBuilder('\OC\User\User') | ||
->disableOriginalConstructor()->getMock(); | ||
$user | ||
->expects($this->exactly(2)) | ||
->expects($this->exactly(3)) | ||
->method('getUID') | ||
->will($this->returnValue('foo')); | ||
$user | ||
|
@@ -648,6 +680,7 @@ public function testIndexWithBackend() { | |
'backend' => 'OC_User_Database', | ||
'email' => null, | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
) | ||
) | ||
); | ||
|
@@ -719,6 +752,7 @@ public function testCreateSuccessfulWithoutGroupAdmin() { | |
'subadmin' => array(), | ||
'email' => null, | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
Http::STATUS_CREATED | ||
); | ||
|
@@ -807,6 +841,7 @@ public function testCreateSuccessfulWithoutGroupSubAdmin() { | |
'subadmin' => [], | ||
'email' => null, | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
Http::STATUS_CREATED | ||
); | ||
|
@@ -889,6 +924,7 @@ public function testCreateSuccessfulWithGroupAdmin() { | |
'subadmin' => array(), | ||
'email' => null, | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
Http::STATUS_CREATED | ||
); | ||
|
@@ -984,6 +1020,7 @@ public function testCreateSuccessfulWithGroupSubAdmin() { | |
'subadmin' => [], | ||
'email' => null, | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
), | ||
Http::STATUS_CREATED | ||
); | ||
|
@@ -1480,6 +1517,7 @@ private function mockUser($userId = 'foo', $displayName = 'M. Foo', | |
'backend' => $backend, | ||
'email' => null, | ||
'isRestoreDisabled' => false, | ||
'isAvatarAvailable' => true, | ||
]; | ||
|
||
return [$user, $result]; | ||
|