From 5fb2eee5df6bfbe3d608709fbe6997860fe4d648 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Fri, 2 Sep 2016 11:02:12 +0200
Subject: [PATCH] Fix getMock user_ldap

---
 apps/user_ldap/tests/AccessTest.php           | 24 +++--
 apps/user_ldap/tests/ConnectionTest.php       |  5 +-
 apps/user_ldap/tests/Group_LDAPTest.php       |  3 +-
 apps/user_ldap/tests/Jobs/CleanUpTest.php     | 10 +-
 .../tests/Mapping/AbstractMappingTest.php     |  4 +-
 apps/user_ldap/tests/User/ManagerTest.php     | 27 ++++--
 apps/user_ldap/tests/User/UserTest.php        | 44 +++++----
 apps/user_ldap/tests/User_LDAPTest.php        | 92 ++++++++++---------
 apps/user_ldap/tests/WizardTest.php           |  3 +-
 9 files changed, 128 insertions(+), 84 deletions(-)

diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php
index 5e99583c70f..08e7c9f79f5 100644
--- a/apps/user_ldap/tests/AccessTest.php
+++ b/apps/user_ldap/tests/AccessTest.php
@@ -28,6 +28,14 @@ namespace OCA\User_LDAP\Tests;
 
 use OCA\User_LDAP\Access;
 use OCA\User_LDAP\Connection;
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUserManager;
 
 /**
  * Class AccessTest
@@ -47,19 +55,19 @@ class AccessTest extends \Test\TestCase {
 			$accMethods = get_class_methods('\OCA\User_LDAP\Access');
 			$umMethods  = get_class_methods('\OCA\User_LDAP\User\Manager');
 		}
-		$lw  = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+		$lw  = $this->createMock(ILDAPWrapper::class);
 		$connector = $this->getMock('\OCA\User_LDAP\Connection',
 									$conMethods,
 									array($lw, null, null));
 		$um = $this->getMock('\OCA\User_LDAP\User\Manager',
 			$umMethods, array(
-				$this->getMock('\OCP\IConfig'),
-				$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(IConfig::class),
+				$this->createMock(FilesystemHelper::class),
+				$this->createMock(LogWrapper::class),
+				$this->createMock(IAvatarManager::class),
+				$this->createMock(Image::class),
+				$this->createMock(IDBConnection::class),
+				$this->createMock(IUserManager::class)));
 		$helper = new \OCA\User_LDAP\Helper();
 
 		return array($lw, $connector, $um, $helper);
diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php
index ed0a1481589..fcff65efb33 100644
--- a/apps/user_ldap/tests/ConnectionTest.php
+++ b/apps/user_ldap/tests/ConnectionTest.php
@@ -25,6 +25,7 @@
 
 namespace OCA\User_LDAP\Tests;
 use OCA\User_LDAP\Connection;
+use OCA\User_LDAP\ILDAPWrapper;
 
 /**
  * Class Test_Connection
@@ -43,7 +44,7 @@ class ConnectionTest extends \Test\TestCase {
 	public function setUp() {
 		parent::setUp();
 
-		$this->ldap       = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+		$this->ldap       = $this->createMock(ILDAPWrapper::class);
 		// we use a mock here to replace the cache mechanism, due to missing DI in LDAP backend.
 		$this->connection = $this->getMockBuilder('OCA\User_LDAP\Connection')
 								 ->setMethods(['getFromCache', 'writeToCache'])
@@ -59,7 +60,7 @@ class ConnectionTest extends \Test\TestCase {
 		//background: upon login a bind is done with the user credentials
 		//which is valid for the whole LDAP resource. It needs to be reset
 		//to the agent's credentials
-		$lw  = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+		$lw  = $this->createMock(ILDAPWrapper::class);
 
 		$connection = new Connection($lw, '', null);
 		$agent = array(
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php
index 83ec2dedf22..12f7eaa2256 100644
--- a/apps/user_ldap/tests/Group_LDAPTest.php
+++ b/apps/user_ldap/tests/Group_LDAPTest.php
@@ -31,6 +31,7 @@ namespace OCA\User_LDAP\Tests;
 use OCA\User_LDAP\Group_LDAP as GroupLDAP;
 use OCA\User_LDAP\Access;
 use OCA\User_LDAP\Connection;
+use OCA\User_LDAP\ILDAPWrapper;
 
 /**
  * Class GroupLDAPTest
@@ -48,7 +49,7 @@ class Group_LDAPTest extends \Test\TestCase {
 			$conMethods = get_class_methods('\OCA\User_LDAP\Connection');
 			$accMethods = get_class_methods('\OCA\User_LDAP\Access');
 		}
-		$lw  = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+		$lw  = $this->createMock(ILDAPWrapper::class);
 		$connector = $this->getMock('\OCA\User_LDAP\Connection',
 									$conMethods,
 									array($lw, null, null));
diff --git a/apps/user_ldap/tests/Jobs/CleanUpTest.php b/apps/user_ldap/tests/Jobs/CleanUpTest.php
index 45e7998da01..62cebcf328e 100644
--- a/apps/user_ldap/tests/Jobs/CleanUpTest.php
+++ b/apps/user_ldap/tests/Jobs/CleanUpTest.php
@@ -24,6 +24,10 @@
 
 namespace OCA\User_LDAP\Tests\Jobs;
 
+use OCA\User_LDAP\Helper;
+use OCP\IConfig;
+use OCP\IDBConnection;
+
 class CleanUpTest extends \Test\TestCase {
 	public function getMocks() {
 		$mocks = array();
@@ -35,9 +39,9 @@ class CleanUpTest extends \Test\TestCase {
 			$this->getMockBuilder('\OCA\User_LDAP\User\DeletedUsersIndex')
 				->disableOriginalConstructor()
 				->getMock();
-		$mocks['ocConfig']    = $this->getMock('\OCP\IConfig');
-		$mocks['db']          = $this->getMock('\OCP\IDBConnection');
-		$mocks['helper']      = $this->getMock('\OCA\User_LDAP\Helper');
+		$mocks['ocConfig']    = $this->createMock(IConfig::class);
+		$mocks['db']          = $this->createMock(IDBConnection::class);
+		$mocks['helper']      = $this->createMock(Helper::class);
 
 		return $mocks;
 	}
diff --git a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
index 1d988126df0..91013085c2c 100644
--- a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
+++ b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
@@ -26,6 +26,8 @@
 
 namespace OCA\User_LDAP\Tests\Mapping;
 
+use OCP\IDBConnection;
+
 abstract class AbstractMappingTest extends \Test\TestCase {
 	abstract public function getMapper(\OCP\IDBConnection $dbMock);
 
@@ -33,7 +35,7 @@ abstract class AbstractMappingTest extends \Test\TestCase {
 	 * kiss test on isColNameValid
 	 */
 	public function testIsColNameValid() {
-		$dbMock = $this->getMock('\OCP\IDBConnection');
+		$dbMock = $this->createMock(IDBConnection::class);
 		$mapper = $this->getMapper($dbMock);
 
 		$this->assertTrue($mapper->isColNameValid('ldap_dn'));
diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php
index b3f22d6a068..16d6a3d9d6e 100644
--- a/apps/user_ldap/tests/User/ManagerTest.php
+++ b/apps/user_ldap/tests/User/ManagerTest.php
@@ -26,7 +26,16 @@
 
 namespace OCA\User_LDAP\Tests\User;
 
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
+use OCA\User_LDAP\User\IUserTools;
 use OCA\User_LDAP\User\Manager;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUserManager;
 
 /**
  * Class Test_User_Manager
@@ -38,17 +47,17 @@ use OCA\User_LDAP\User\Manager;
 class ManagerTest extends \Test\TestCase {
 
 	private function getTestInstances() {
-		$access = $this->getMock('\OCA\User_LDAP\User\IUserTools');
-		$config = $this->getMock('\OCP\IConfig');
-		$filesys = $this->getMock('\OCA\User_LDAP\FilesystemHelper');
-		$log = $this->getMock('\OCA\User_LDAP\LogWrapper');
-		$avaMgr = $this->getMock('\OCP\IAvatarManager');
-		$image = $this->getMock('\OCP\Image');
-		$dbc = $this->getMock('\OCP\IDBConnection');
-		$userMgr = $this->getMock('\OCP\IUserManager');
+		$access = $this->createMock(IUserTools::class);
+		$config = $this->createMock(IConfig::class);
+		$filesys = $this->createMock(FilesystemHelper::class);
+		$log = $this->createMock(LogWrapper::class);
+		$avaMgr = $this->createMock(IAvatarManager::class);
+		$image = $this->createMock(Image::class);
+		$dbc = $this->createMock(IDBConnection::class);
+		$userMgr = $this->createMock(IUserManager::class);
 
 		$connection = new \OCA\User_LDAP\Connection(
-			$lw  = $this->getMock('\OCA\User_LDAP\ILDAPWrapper'),
+			$lw  = $this->createMock(ILDAPWrapper::class),
 			'',
 			null
 		);
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php
index d9e43dee047..6e6e2ad66b1 100644
--- a/apps/user_ldap/tests/User/UserTest.php
+++ b/apps/user_ldap/tests/User/UserTest.php
@@ -25,7 +25,17 @@
 
 namespace OCA\User_LDAP\Tests\User;
 
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
+use OCA\User_LDAP\User\IUserTools;
 use OCA\User_LDAP\User\User;
+use OCP\IAvatar;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUser;
 use OCP\IUserManager;
 
 /**
@@ -38,14 +48,14 @@ use OCP\IUserManager;
 class UserTest extends \Test\TestCase {
 
 	private function getTestInstances() {
-		$access  = $this->getMock('\OCA\User_LDAP\User\IUserTools');
-		$config  = $this->getMock('\OCP\IConfig');
-		$filesys = $this->getMock('\OCA\User_LDAP\FilesystemHelper');
-		$log     = $this->getMock('\OCA\User_LDAP\LogWrapper');
-		$avaMgr  = $this->getMock('\OCP\IAvatarManager');
-		$image   = $this->getMock('\OCP\Image');
-		$dbc     = $this->getMock('\OCP\IDBConnection');
-		$userMgr  = $this->getMock('\OCP\IUserManager');
+		$access  = $this->createMock(IUserTools::class);
+		$config  = $this->createMock(IConfig::class);
+		$filesys = $this->createMock(FilesystemHelper::class);
+		$log     = $this->createMock(LogWrapper::class);
+		$avaMgr  = $this->createMock(IAvatarManager::class);
+		$image   = $this->createMock(Image::class);
+		$dbc     = $this->createMock(IDBConnection::class);
+		$userMgr  = $this->createMock(IUserManager::class);
 
 		return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr);
 	}
@@ -62,10 +72,10 @@ class UserTest extends \Test\TestCase {
 			unset($accMethods[array_search('getConnection', $accMethods)]);
 			$umMethods = get_class_methods('\OCA\User_LDAP\User\Manager');
 		}
-		$lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
-		$im = $this->getMock('\OCP\Image');
+		$lw = $this->createMock(ILDAPWrapper::class);
+		$im = $this->createMock(Image::class);
 		if (is_null($userMgr)) {
-			$userMgr = $this->getMock('\OCP\IUserManager');
+			$userMgr = $this->createMock(IUserManager::class);
 		}
 		$um = $this->getMock('\OCA\User_LDAP\User\Manager',
 			$umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr));
@@ -212,7 +222,7 @@ class UserTest extends \Test\TestCase {
 				$this->equalTo('myquota'))
 			->will($this->returnValue(array('42 GB')));
 
-		$user = $this->getMock('\OCP\IUser');
+		$user = $this->createMock(IUser::class);
 		$user->expects($this->once())
 			->method('setQuota')
 			->with('42 GB');
@@ -257,7 +267,7 @@ class UserTest extends \Test\TestCase {
 				$this->equalTo('myquota'))
 			->will($this->returnValue(false));
 
-		$user = $this->getMock('\OCP\IUser');
+		$user = $this->createMock(IUser::class);
 		$user->expects($this->once())
 			->method('setQuota')
 			->with('25 GB');
@@ -302,7 +312,7 @@ class UserTest extends \Test\TestCase {
 				$this->equalTo('myquota'))
 			->will($this->returnValue(array('27 GB')));
 
-		$user = $this->getMock('\OCP\IUser');
+		$user = $this->createMock(IUser::class);
 		$user->expects($this->once())
 			->method('setQuota')
 			->with('27 GB');
@@ -416,7 +426,7 @@ class UserTest extends \Test\TestCase {
 		$access->expects($this->never())
 			->method('readAttribute');
 
-		$user = $this->getMock('\OCP\IUser');
+		$user = $this->createMock(IUser::class);
 		$user->expects($this->once())
 			->method('setQuota')
 			->with($readQuota);
@@ -466,7 +476,7 @@ class UserTest extends \Test\TestCase {
 			->method('isLoaded')
 			->will($this->returnValue(true));
 
-		$avatar = $this->getMock('\OCP\IAvatar');
+		$avatar = $this->createMock(IAvatar::class);
 		$avatar->expects($this->once())
 			->method('set')
 			->with($this->isInstanceOf($image));
@@ -524,7 +534,7 @@ class UserTest extends \Test\TestCase {
 			->method('isLoaded')
 			->will($this->returnValue(true));
 
-		$avatar = $this->getMock('\OCP\IAvatar');
+		$avatar = $this->createMock(IAvatar::class);
 		$avatar->expects($this->once())
 			->method('set')
 			->with($this->isInstanceOf($image));
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);
diff --git a/apps/user_ldap/tests/WizardTest.php b/apps/user_ldap/tests/WizardTest.php
index e82cbcfc82a..3aefa8779a2 100644
--- a/apps/user_ldap/tests/WizardTest.php
+++ b/apps/user_ldap/tests/WizardTest.php
@@ -26,6 +26,7 @@
 
 namespace OCA\User_LDAP\Tests;
 
+use OCA\User_LDAP\ILDAPWrapper;
 use \OCA\User_LDAP\Wizard;
 
 /**
@@ -59,7 +60,7 @@ class WizardTest extends \Test\TestCase {
 			$connMethods = get_class_methods('\OCA\User_LDAP\Connection');
 			$accMethods  = get_class_methods('\OCA\User_LDAP\Access');
 		}
-		$lw   = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+		$lw   = $this->createMock(ILDAPWrapper::class);
 		$conf = $this->getMock('\OCA\User_LDAP\Configuration',
 							   $confMethods,
 							   array($lw, null, null));
-- 
GitLab