diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-19 15:48:38 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-20 15:21:33 +0100 |
commit | 77069f5582ad42207ee9a9620cba5720390d9e79 (patch) | |
tree | bf1ac115fd972c6d061a2f50df903491c02f97e8 /apps/user_ldap/tests/user/user.php | |
parent | 51b50bd26049eed0d4335ae5f5282f53df0189a1 (diff) | |
download | nextcloud-server-77069f5582ad42207ee9a9620cba5720390d9e79.tar.gz nextcloud-server-77069f5582ad42207ee9a9620cba5720390d9e79.zip |
Use IUser::setEMailAddress in ldap as well
Diffstat (limited to 'apps/user_ldap/tests/user/user.php')
-rw-r--r-- | apps/user_ldap/tests/user/user.php | 120 |
1 files changed, 64 insertions, 56 deletions
diff --git a/apps/user_ldap/tests/user/user.php b/apps/user_ldap/tests/user/user.php index 9b3bb4ace66..6fa7f3b6b27 100644 --- a/apps/user_ldap/tests/user/user.php +++ b/apps/user_ldap/tests/user/user.php @@ -25,6 +25,7 @@ namespace OCA\user_ldap\tests; use OCA\user_ldap\lib\user\User; +use OCP\IUserManager; /** * Class Test_User_User @@ -43,11 +44,12 @@ class Test_User_User extends \Test\TestCase { $avaMgr = $this->getMock('\OCP\IAvatarManager'); $image = $this->getMock('\OCP\Image'); $dbc = $this->getMock('\OCP\IDBConnection'); + $userMgr = $this->getMock('\OCP\IUserManager'); - return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc); + return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr); } - private function getAdvancedMocks($cfMock, $fsMock, $logMock, $avaMgr, $dbc) { + private function getAdvancedMocks($cfMock, $fsMock, $logMock, $avaMgr, $dbc, $userMgr = null) { static $conMethods; static $accMethods; static $umMethods; @@ -61,8 +63,11 @@ class Test_User_User extends \Test\TestCase { } $lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper'); $im = $this->getMock('\OCP\Image'); + if (is_null($userMgr)) { + $userMgr = $this->getMock('\OCP\IUserManager'); + } $um = $this->getMock('\OCA\user_ldap\lib\user\Manager', - $umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc)); + $umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr)); $connector = $this->getMock('\OCA\user_ldap\lib\Connection', $conMethods, array($lw, null, null)); $access = $this->getMock('\OCA\user_ldap\lib\Access', @@ -72,25 +77,25 @@ class Test_User_User extends \Test\TestCase { } public function testGetDNandUsername() { - list($access, $config, $filesys, $image, $log, $avaMgr) = + list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) = $this->getTestInstances(); $uid = 'alice'; $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $this->assertSame($dn, $user->getDN()); $this->assertSame($uid, $user->getUsername()); } public function testUpdateEmailProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = - $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr); $connection->expects($this->once()) ->method('__get') @@ -103,24 +108,27 @@ class Test_User_User extends \Test\TestCase { $this->equalTo('email')) ->will($this->returnValue(array('alice@foo.bar'))); - $config->expects($this->once()) - ->method('setUserValue') - ->with($this->equalTo('alice'), $this->equalTo('settings'), - $this->equalTo('email'), - $this->equalTo('alice@foo.bar')) - ->will($this->returnValue(true)); - $uid = 'alice'; $dn = 'uid=alice,dc=foo,dc=bar'; + $uuser = $this->getMockBuilder('\OCP\IUser') + ->disableOriginalConstructor() + ->getMock(); + $uuser->expects($this->once()) + ->method('setEMailAddress') + ->with('alice@foo.bar'); + /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject $userMgr */ + $userMgr->expects($this->any()) + ->method('get') + ->willReturn($uuser); $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateEmail(); } public function testUpdateEmailNotProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -144,13 +152,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateEmail(); } public function testUpdateEmailNotConfigured() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -171,13 +179,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateEmail(); } public function testUpdateQuotaAllProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -214,13 +222,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateQuota(); } public function testUpdateQuotaDefaultProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -257,13 +265,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateQuota(); } public function testUpdateQuotaIndividualProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -300,13 +308,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateQuota(); } public function testUpdateQuotaNoneProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -338,13 +346,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateQuota(); } public function testUpdateQuotaNoneConfigured() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -373,13 +381,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateQuota(); } public function testUpdateQuotaFromValue() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -412,14 +420,14 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateQuota($readQuota); } //the testUpdateAvatar series also implicitely tests getAvatarImage public function testUpdateAvatarJpegPhotoProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -462,13 +470,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateAvatar(); } public function testUpdateAvatarThumbnailPhotoProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -520,13 +528,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateAvatar(); } public function testUpdateAvatarNotProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -566,13 +574,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->updateAvatar(); } public function testUpdateBeforeFirstLogin() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -602,13 +610,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->update(); } public function testUpdateAfterFirstLogin() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -642,13 +650,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->update(); } public function testUpdateNoRefresh() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -678,13 +686,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->update(); } public function testMarkLogin() { - list($access, $config, $filesys, $image, $log, $avaMgr) = + list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) = $this->getTestInstances(); $config->expects($this->once()) @@ -699,13 +707,13 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->markLogin(); } public function testGetAvatarImageProvided() { - list($access, $config, $filesys, $image, $log, $avaMgr) = + list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) = $this->getTestInstances(); $access->expects($this->once()) @@ -718,7 +726,7 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $photo = $user->getAvatarImage(); $this->assertSame('this is a photo', $photo); @@ -728,7 +736,7 @@ class Test_User_User extends \Test\TestCase { } public function testProcessAttributes() { - list(, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -748,7 +756,7 @@ class Test_User_User extends \Test\TestCase { ); $userMock = $this->getMockBuilder('OCA\user_ldap\lib\user\User') - ->setConstructorArgs(array($uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr)) + ->setConstructorArgs(array($uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr)) ->setMethods($requiredMethods) ->getMock(); @@ -795,7 +803,7 @@ class Test_User_User extends \Test\TestCase { * @dataProvider emptyHomeFolderAttributeValueProvider */ public function testGetHomePathNotConfigured($attributeValue) { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -816,14 +824,14 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $path = $user->getHomePath(); $this->assertSame($path, false); } public function testGetHomePathConfiguredNotAvailableAllowed() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = @@ -847,7 +855,7 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $path = $user->getHomePath(); @@ -858,11 +866,11 @@ class Test_User_User extends \Test\TestCase { * @expectedException \Exception */ public function testGetHomePathConfiguredNotAvailableNotAllowed() { - list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = $this->getTestInstances(); list($access, $connection) = - $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr); $connection->expects($this->any()) ->method('__get') @@ -882,7 +890,7 @@ class Test_User_User extends \Test\TestCase { $dn = 'uid=alice,dc=foo,dc=bar'; $user = new User( - $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr); $user->getHomePath(); } |