diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-09-02 11:02:12 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-09-06 09:29:27 +0200 |
commit | 5fb2eee5df6bfbe3d608709fbe6997860fe4d648 (patch) | |
tree | c94f53f8128e92268ff10755066f3d0d2ef76b38 /apps/user_ldap/tests/User_LDAPTest.php | |
parent | 798dd401391bc9d88292b50f9a17f01546f70624 (diff) | |
download | nextcloud-server-5fb2eee5df6bfbe3d608709fbe6997860fe4d648.tar.gz nextcloud-server-5fb2eee5df6bfbe3d608709fbe6997860fe4d648.zip |
Fix getMock user_ldap
Diffstat (limited to 'apps/user_ldap/tests/User_LDAPTest.php')
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 92 |
1 files changed, 50 insertions, 42 deletions
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 47e789142e5..0e08998d13b 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -28,9 +28,17 @@ namespace OCA\User_LDAP\Tests; +use OCA\User_LDAP\FilesystemHelper; +use OCA\User_LDAP\ILDAPWrapper; +use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\User_LDAP as UserLDAP; use \OCA\User_LDAP\Access; use \OCA\User_LDAP\Connection; +use OCP\IAvatarManager; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\Image; +use OCP\IUserManager; /** * Class Test_User_Ldap_Direct @@ -65,12 +73,12 @@ class User_LDAPTest extends \Test\TestCase { unset($uMethods[array_search('getDN', $uMethods)]); unset($uMethods[array_search('__construct', $uMethods)]); } - $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper'); + $lw = $this->createMock(ILDAPWrapper::class); $connector = $this->getMock('\OCA\User_LDAP\Connection', $conMethods, array($lw, null, null)); - $this->configMock = $this->getMock('\OCP\IConfig'); + $this->configMock = $this->createMock(IConfig::class); $offlineUser = $this->getMockBuilder('\OCA\User_LDAP\User\OfflineUser') ->disableOriginalConstructor() @@ -80,12 +88,12 @@ class User_LDAPTest extends \Test\TestCase { ->setMethods(['getDeletedUser']) ->setConstructorArgs([ $this->configMock, - $this->getMock('\OCA\User_LDAP\FilesystemHelper'), - $this->getMock('\OCA\User_LDAP\LogWrapper'), - $this->getMock('\OCP\IAvatarManager'), - $this->getMock('\OCP\Image'), - $this->getMock('\OCP\IDBConnection'), - $this->getMock('\OCP\IUserManager') + $this->createMock(FilesystemHelper::class), + $this->createMock(LogWrapper::class), + $this->createMock(IAvatarManager::class), + $this->createMock(Image::class), + $this->createMock(IDBConnection::class), + $this->createMock(IUserManager::class) ]) ->getMock(); @@ -189,7 +197,7 @@ class User_LDAPTest extends \Test\TestCase { $access = $this->getAccessMock(); $this->prepareAccessForCheckPassword($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'dt19'); @@ -200,7 +208,7 @@ class User_LDAPTest extends \Test\TestCase { $access = $this->getAccessMock(); $this->prepareAccessForCheckPassword($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'wrong'); @@ -211,7 +219,7 @@ class User_LDAPTest extends \Test\TestCase { $access = $this->getAccessMock(); $this->prepareAccessForCheckPassword($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = $backend->checkPassword('mallory', 'evil'); @@ -226,7 +234,7 @@ class User_LDAPTest extends \Test\TestCase { ->method('username2dn') ->will($this->returnValue(false)); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = $backend->checkPassword('roland', 'dt19'); @@ -236,7 +244,7 @@ class User_LDAPTest extends \Test\TestCase { public function testCheckPasswordPublicAPI() { $access = $this->getAccessMock(); $this->prepareAccessForCheckPassword($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::checkPassword('roland', 'dt19'); @@ -246,7 +254,7 @@ class User_LDAPTest extends \Test\TestCase { public function testCheckPasswordPublicAPIWrongPassword() { $access = $this->getAccessMock(); $this->prepareAccessForCheckPassword($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::checkPassword('roland', 'wrong'); @@ -256,7 +264,7 @@ class User_LDAPTest extends \Test\TestCase { public function testCheckPasswordPublicAPIWrongUser() { $access = $this->getAccessMock(); $this->prepareAccessForCheckPassword($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::checkPassword('mallory', 'evil'); @@ -265,7 +273,7 @@ class User_LDAPTest extends \Test\TestCase { public function testDeleteUserCancel() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->deleteUser('notme'); $this->assertFalse($result); } @@ -282,7 +290,7 @@ class User_LDAPTest extends \Test\TestCase { ->method('getUserMapper') ->will($this->returnValue($mapping)); - $config = $this->getMock('\OCP\IConfig'); + $config = $this->createMock(IConfig::class); $config->expects($this->exactly(2)) ->method('getUserValue') ->will($this->onConsecutiveCalls('1', '/var/vhome/jdings/')); @@ -348,7 +356,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersNoParam() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->getUsers(); $this->assertEquals(3, count($result)); @@ -357,7 +365,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersLimitOffset() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->getUsers('', 1, 2); $this->assertEquals(1, count($result)); @@ -366,7 +374,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersLimitOffset2() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->getUsers('', 2, 1); $this->assertEquals(2, count($result)); @@ -375,7 +383,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersSearchWithResult() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->getUsers('yo'); $this->assertEquals(2, count($result)); @@ -384,7 +392,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersSearchEmptyResult() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->getUsers('nix'); $this->assertEquals(0, count($result)); @@ -393,7 +401,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersViaAPINoParam() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::getUsers(); @@ -403,7 +411,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersViaAPILimitOffset() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::getUsers('', 1, 2); @@ -413,7 +421,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersViaAPILimitOffset2() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::getUsers('', 2, 1); @@ -423,7 +431,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersViaAPISearchWithResult() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::getUsers('yo'); @@ -433,7 +441,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetUsersViaAPISearchEmptyResult() { $access = $this->getAccessMock(); $this->prepareAccessForGetUsers($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); \OC_User::useBackend($backend); $result = \OCP\User::getUsers('nix'); @@ -442,7 +450,7 @@ class User_LDAPTest extends \Test\TestCase { public function testUserExists() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->expects($this->any()) @@ -464,7 +472,7 @@ class User_LDAPTest extends \Test\TestCase { */ public function testUserExistsForDeleted() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->expects($this->any()) @@ -482,7 +490,7 @@ class User_LDAPTest extends \Test\TestCase { public function testUserExistsForNeverExisting() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->expects($this->any()) @@ -501,7 +509,7 @@ class User_LDAPTest extends \Test\TestCase { public function testUserExistsPublicAPI() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); \OC_User::useBackend($backend); @@ -524,7 +532,7 @@ class User_LDAPTest extends \Test\TestCase { */ public function testUserExistsPublicAPIForDeleted() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); \OC_User::useBackend($backend); @@ -543,7 +551,7 @@ class User_LDAPTest extends \Test\TestCase { public function testUserExistsPublicAPIForNeverExisting() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); \OC_User::useBackend($backend); @@ -563,7 +571,7 @@ class User_LDAPTest extends \Test\TestCase { public function testDeleteUser() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); //we do not support deleting users at all $result = $backend->deleteUser('gunslinger'); @@ -572,7 +580,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetHomeAbsolutePath() { $access = $this->getAccessMock(); - $config = $this->getMock('\OCP\IConfig'); + $config = $this->createMock(IConfig::class); $backend = new UserLDAP($access, $config); $this->prepareMockForUserExists($access); @@ -607,7 +615,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetHomeRelative() { $access = $this->getAccessMock(); - $config = $this->getMock('\OCP\IConfig'); + $config = $this->createMock(IConfig::class); $backend = new UserLDAP($access, $config); $this->prepareMockForUserExists($access); @@ -651,7 +659,7 @@ class User_LDAPTest extends \Test\TestCase { */ public function testGetHomeNoPath() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->connection->expects($this->any()) @@ -682,7 +690,7 @@ class User_LDAPTest extends \Test\TestCase { */ public function testGetHomeDeletedUser() { $access = $this->getAccessMock(); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->connection->expects($this->any()) @@ -753,7 +761,7 @@ class User_LDAPTest extends \Test\TestCase { public function testGetDisplayName() { $access = $this->getAccessMock(); $this->prepareAccessForGetDisplayName($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->connection->expects($this->any()) @@ -794,7 +802,7 @@ class User_LDAPTest extends \Test\TestCase { } })); $this->prepareAccessForGetDisplayName($access); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $this->prepareMockForUserExists($access); $access->connection->expects($this->any()) @@ -824,7 +832,7 @@ class User_LDAPTest extends \Test\TestCase { ->method('countUsers') ->will($this->returnValue(5)); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->countUsers(); $this->assertEquals(5, $result); @@ -837,7 +845,7 @@ class User_LDAPTest extends \Test\TestCase { ->method('countUsers') ->will($this->returnValue(false)); - $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig')); + $backend = new UserLDAP($access, $this->createMock(IConfig::class)); $result = $backend->countUsers(); $this->assertFalse($result); |