diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-09-04 15:44:48 +0300 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-09-04 15:44:48 +0300 |
commit | 8d2f7124201d1364e29feecedb52b96907cf0347 (patch) | |
tree | 04c47e0e50f3c2c013d8327d76aff1a2d4ac3bd7 /apps/user_ldap/tests | |
parent | 0e19e55e242af3e665035f5928d293ed9addc4ed (diff) |
Don't process known avatars from LDAP
* avoids useless FS operation
* avoids useless DB writes
* avoids useless addressbook updates
* addendum to #17001
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r-- | apps/user_ldap/tests/User/UserTest.php | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index f99100789d8..c4563bf1f31 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -521,6 +521,17 @@ class UserTest extends \Test\TestCase { $this->image->expects($this->once()) ->method('centerCrop') ->will($this->returnValue(true)); + $this->image->expects($this->once()) + ->method('data') + ->will($this->returnValue('this is a photo')); + + $this->config->expects($this->once()) + ->method('getUserValue') + ->with($this->uid, 'user_ldap', 'lastAvatarChecksum', '') + ->willReturn(''); + $this->config->expects($this->once()) + ->method('setUserValue') + ->with($this->uid, 'user_ldap', 'lastAvatarChecksum', md5('this is a photo')); $this->filesystemhelper->expects($this->once()) ->method('isLoaded') @@ -544,6 +555,53 @@ class UserTest extends \Test\TestCase { $this->user->updateAvatar(); } + public function testUpdateAvatarKnownJpegPhotoProvided() { + $this->access->expects($this->once()) + ->method('readAttribute') + ->with($this->equalTo($this->dn), + $this->equalTo('jpegphoto')) + ->will($this->returnValue(['this is a photo'])); + + $this->image->expects($this->once()) + ->method('loadFromBase64') + ->willReturn('imageResource'); + $this->image->expects($this->never()) + ->method('valid'); + $this->image->expects($this->never()) + ->method('width'); + $this->image->expects($this->never()) + ->method('height'); + $this->image->expects($this->never()) + ->method('centerCrop'); + $this->image->expects($this->once()) + ->method('data') + ->will($this->returnValue('this is a photo')); + + $this->config->expects($this->once()) + ->method('getUserValue') + ->with($this->uid, 'user_ldap', 'lastAvatarChecksum', '') + ->willReturn(md5('this is a photo')); + $this->config->expects($this->never()) + ->method('setUserValue'); + + $this->filesystemhelper->expects($this->never()) + ->method('isLoaded'); + + $avatar = $this->createMock(IAvatar::class); + $avatar->expects($this->never()) + ->method('set'); + + $this->avatarManager->expects($this->never()) + ->method('getAvatar'); + + $this->connection->expects($this->any()) + ->method('resolveRule') + ->with('avatar') + ->willReturn(['jpegphoto', 'thumbnailphoto']); + + $this->assertTrue($this->user->updateAvatar()); + } + public function testUpdateAvatarThumbnailPhotoProvided() { $this->access->expects($this->any()) ->method('readAttribute') @@ -575,6 +633,17 @@ class UserTest extends \Test\TestCase { $this->image->expects($this->once()) ->method('centerCrop') ->will($this->returnValue(true)); + $this->image->expects($this->once()) + ->method('data') + ->will($this->returnValue('this is a photo')); + + $this->config->expects($this->once()) + ->method('getUserValue') + ->with($this->uid, 'user_ldap', 'lastAvatarChecksum', '') + ->willReturn(''); + $this->config->expects($this->once()) + ->method('setUserValue') + ->with($this->uid, 'user_ldap', 'lastAvatarChecksum', md5('this is a photo')); $this->filesystemhelper->expects($this->once()) ->method('isLoaded') @@ -625,6 +694,13 @@ class UserTest extends \Test\TestCase { ->method('height'); $this->image->expects($this->never()) ->method('centerCrop'); + $this->image->expects($this->never()) + ->method('data'); + + $this->config->expects($this->never()) + ->method('getUserValue'); + $this->config->expects($this->never()) + ->method('setUserValue'); $this->filesystemhelper->expects($this->never()) ->method('isLoaded'); @@ -675,6 +751,16 @@ class UserTest extends \Test\TestCase { $this->image->expects($this->once()) ->method('centerCrop') ->will($this->returnValue(true)); + $this->image->expects($this->once()) + ->method('data') + ->will($this->returnValue('this is a photo')); + + $this->config->expects($this->once()) + ->method('getUserValue') + ->with($this->uid, 'user_ldap', 'lastAvatarChecksum', '') + ->willReturn(''); + $this->config->expects($this->never()) + ->method('setUserValue'); $this->filesystemhelper->expects($this->once()) ->method('isLoaded') @@ -723,6 +809,13 @@ class UserTest extends \Test\TestCase { ->method('height'); $this->image->expects($this->never()) ->method('centerCrop'); + $this->image->expects($this->never()) + ->method('data'); + + $this->config->expects($this->never()) + ->method('getUserValue'); + $this->config->expects($this->never()) + ->method('setUserValue'); $this->filesystemhelper->expects($this->never()) ->method('isLoaded'); |