diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php
index 5661ab7033ffcac1aba4f1ad5dee7bbae63f9250..4f3e09687e3d42a718815e29bdbc10475b9e6bc9 100644
--- a/apps/encryption/tests/Controller/SettingsControllerTest.php
+++ b/apps/encryption/tests/Controller/SettingsControllerTest.php
@@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests\Controller;
 use OCA\Encryption\Controller\SettingsController;
 use OCA\Encryption\Session;
 use OCP\AppFramework\Http;
+use OCP\IRequest;
 use Test\TestCase;
 
 class SettingsControllerTest extends TestCase {
@@ -64,7 +65,7 @@ class SettingsControllerTest extends TestCase {
 
 		parent::setUp();
 
-		$this->requestMock = $this->getMock('OCP\IRequest');
+		$this->requestMock = $this->createMock(IRequest::class);
 
 		$this->l10nMock = $this->getMockBuilder('OCP\IL10N')
 			->disableOriginalConstructor()->getMock();
diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php
index 17cec468438b82cb42c18649da02453ae6b8c80d..c6c92e2aac23aa01e0a50bd6a0407792d3ab2b6c 100644
--- a/apps/encryption/tests/Controller/StatusControllerTest.php
+++ b/apps/encryption/tests/Controller/StatusControllerTest.php
@@ -27,6 +27,7 @@ namespace OCA\Encryption\Tests\Controller;
 
 use OCA\Encryption\Controller\StatusController;
 use OCA\Encryption\Session;
+use OCP\IRequest;
 use Test\TestCase;
 
 class StatusControllerTest extends TestCase {
@@ -49,7 +50,7 @@ class StatusControllerTest extends TestCase {
 
 		$this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session')
 			->disableOriginalConstructor()->getMock();
-		$this->requestMock = $this->getMock('OCP\IRequest');
+		$this->requestMock = $this->createMock(IRequest::class);
 
 		$this->l10nMock = $this->getMockBuilder('OCP\IL10N')
 			->disableOriginalConstructor()->getMock();
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index 7bd06471b53b8c5fa850ec1cc39538e1a9b46ae8..b808acaf199abd11035331758b736db3fff6cb6e 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -27,6 +27,7 @@ namespace OCA\Encryption\Tests\Crypto;
 
 
 use OCA\Encryption\Crypto\Crypt;
+use OCP\IL10N;
 use Test\TestCase;
 
 class CryptTest extends TestCase {
@@ -62,7 +63,7 @@ class CryptTest extends TestCase {
 		$this->config = $this->getMockBuilder('OCP\IConfig')
 			->disableOriginalConstructor()
 			->getMock();
-		$this->l = $this->getMock('OCP\IL10N');
+		$this->l = $this->createMock(IL10N::class);
 
 		$this->crypt = new Crypt($this->logger, $this->userSession, $this->config, $this->l);
 	}
diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php
index 8232af5f9f2e17053a43a7b30fd8c79abc544181..6c279a54f57872a61413123f96d4df83555f5c08 100644
--- a/apps/encryption/tests/Crypto/EncryptAllTest.php
+++ b/apps/encryption/tests/Crypto/EncryptAllTest.php
@@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests\Crypto;
 
 
 use OCA\Encryption\Crypto\EncryptAll;
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
 use Test\TestCase;
 
 class EncryptAllTest extends TestCase {
@@ -101,7 +102,7 @@ class EncryptAllTest extends TestCase {
 
 
 		$this->outputInterface->expects($this->any())->method('getFormatter')
-			->willReturn($this->getMock('\Symfony\Component\Console\Formatter\OutputFormatterInterface'));
+			->willReturn($this->createMock(OutputFormatterInterface::class));
 
 		$this->userManager->expects($this->any())->method('getBackends')->willReturn([$this->userInterface]);
 		$this->userInterface->expects($this->any())->method('getUsers')->willReturn(['user1', 'user2']);
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 4d8b6bbbf2fe486950bca4dcad44662b7321f2be..658f6275bb4048e864af54b1a2f1dfc3bd19da87 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -24,6 +24,8 @@
 namespace OCA\Encryption\Tests\Crypto;
 
 use OCA\Encryption\Exceptions\PublicKeyMissingException;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
 use Test\TestCase;
 use OCA\Encryption\Crypto\Encryption;
 
@@ -412,9 +414,9 @@ class EncryptionTest extends TestCase {
 
 	public function testPrepareDecryptAll() {
 		/** @var \Symfony\Component\Console\Input\InputInterface $input */
-		$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
+		$input = $this->createMock(InputInterface::class);
 		/** @var \Symfony\Component\Console\Output\OutputInterface $output */
-		$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+		$output = $this->createMock(OutputInterface::class);
 
 		$this->decryptAllMock->expects($this->once())->method('prepare')
 			->with($input, $output, 'user');
diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php
index 6ccca3d2afa17cd6f715951b765660f51fcb7309..43cc54f890122ebdc83a02a918055b2adc1c1846 100644
--- a/apps/encryption/tests/Hooks/UserHooksTest.php
+++ b/apps/encryption/tests/Hooks/UserHooksTest.php
@@ -29,6 +29,8 @@ namespace OCA\Encryption\Tests\Hooks;
 
 use OCA\Encryption\Crypto\Crypt;
 use OCA\Encryption\Hooks\UserHooks;
+use OCP\ILogger;
+use OCP\IUser;
 use Test\TestCase;
 
 /**
@@ -141,7 +143,7 @@ class UserHooksTest extends TestCase {
 			->setMethods(['setPassphrase'])
 			->getMock();
 
-		$userMock = $this->getMock('OCP\IUser');
+		$userMock = $this->createMock(IUser::class);
 
 		$this->userManagerMock->expects($this->once())
 			->method('get')
@@ -300,7 +302,7 @@ class UserHooksTest extends TestCase {
 
 	protected function setUp() {
 		parent::setUp();
-		$this->loggerMock = $this->getMock('OCP\ILogger');
+		$this->loggerMock = $this->createMock(ILogger::class);
 		$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')
 			->disableOriginalConstructor()
 			->getMock();
diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php
index 9ac3befdfcb400abeae609a76b6af87f7e327918..fec311afa35fe1d59b18e5afcb9db8c806c75f6a 100644
--- a/apps/encryption/tests/KeyManagerTest.php
+++ b/apps/encryption/tests/KeyManagerTest.php
@@ -29,6 +29,10 @@ namespace OCA\Encryption\Tests;
 
 use OCA\Encryption\KeyManager;
 use OCA\Encryption\Session;
+use OCP\Encryption\Keys\IStorage;
+use OCP\IConfig;
+use OCP\ILogger;
+use OCP\IUserSession;
 use Test\TestCase;
 
 class KeyManagerTest extends TestCase {
@@ -69,19 +73,19 @@ class KeyManagerTest extends TestCase {
 		parent::setUp();
 		$this->userId = 'user1';
 		$this->systemKeyId = 'systemKeyId';
-		$this->keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
+		$this->keyStorageMock = $this->createMock(IStorage::class);
 		$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')
 			->disableOriginalConstructor()
 			->getMock();
-		$this->configMock = $this->getMock('OCP\IConfig');
+		$this->configMock = $this->createMock(IConfig::class);
 		$this->configMock->expects($this->any())
 			->method('getAppValue')
 			->willReturn($this->systemKeyId);
-		$this->userMock = $this->getMock('OCP\IUserSession');
+		$this->userMock = $this->createMock(IUserSession::class);
 		$this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session')
 			->disableOriginalConstructor()
 			->getMock();
-		$this->logMock = $this->getMock('OCP\ILogger');
+		$this->logMock = $this->createMock(ILogger::class);
 		$this->utilMock = $this->getMockBuilder('OCA\Encryption\Util')
 			->disableOriginalConstructor()
 			->getMock();
diff --git a/apps/encryption/tests/MigrationTest.php b/apps/encryption/tests/MigrationTest.php
index 3126dd2ff2cbb59da863b2c3dc1d796eb850f9ff..0aea7543c2c961f27f403fae8dcc853770aa07bb 100644
--- a/apps/encryption/tests/MigrationTest.php
+++ b/apps/encryption/tests/MigrationTest.php
@@ -28,6 +28,12 @@ namespace OCA\Encryption\Tests;
 use OCA\Encryption\Migration;
 use OCP\ILogger;
 
+/**
+ * Class MigrationTest
+ *
+ * @package OCA\Encryption\Tests
+ * @group DB
+ */
 class MigrationTest extends \Test\TestCase {
 
 	const TEST_ENCRYPTION_MIGRATION_USER1='test_encryption_user1';
diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php
index 477913a1a69eafd28fc511e67293973d09b3a389..d73b5d48c912717498b14b2e097e44b6298e3fe6 100644
--- a/apps/encryption/tests/RecoveryTest.php
+++ b/apps/encryption/tests/RecoveryTest.php
@@ -27,7 +27,12 @@
 namespace OCA\Encryption\Tests;
 
 
+use OC\Files\View;
 use OCA\Encryption\Recovery;
+use OCP\Encryption\IFile;
+use OCP\Encryption\Keys\IStorage;
+use OCP\IConfig;
+use OCP\Security\ISecureRandom;
 use Test\TestCase;
 
 class RecoveryTest extends TestCase {
@@ -268,13 +273,13 @@ class RecoveryTest extends TestCase {
 
 		$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock();
 		/** @var \OCP\Security\ISecureRandom $randomMock */
-		$randomMock = $this->getMock('OCP\Security\ISecureRandom');
+		$randomMock = $this->createMock(ISecureRandom::class);
 		$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock();
-		$this->configMock = $this->getMock('OCP\IConfig');
+		$this->configMock = $this->createMock(IConfig::class);
 		/** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */
-		$keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
-		$this->fileMock = $this->getMock('OCP\Encryption\IFile');
-		$this->viewMock = $this->getMock('OC\Files\View');
+		$keyStorageMock = $this->createMock(IStorage::class);
+		$this->fileMock = $this->createMock(IFile::class);
+		$this->viewMock = $this->createMock(View::class);
 
 		$this->configMock->expects($this->any())
 			->method('setAppValue')
diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php
index 1a22726f5b15f6ac667f713fb56a3685c7ad305c..099acddbca1f136aa0ef919e9caf4e167a25e61d 100644
--- a/apps/encryption/tests/SessionTest.php
+++ b/apps/encryption/tests/SessionTest.php
@@ -28,6 +28,7 @@ namespace OCA\Encryption\Tests;
 
 
 use OCA\Encryption\Session;
+use OCP\ISession;
 use Test\TestCase;
 
 class SessionTest extends TestCase {
@@ -175,7 +176,7 @@ class SessionTest extends TestCase {
 	 */
 	protected function setUp() {
 		parent::setUp();
-		$this->sessionMock = $this->getMock('OCP\ISession');
+		$this->sessionMock = $this->createMock(ISession::class);
 
 		$this->sessionMock->expects($this->any())
 			->method('set')
diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php
index 252092f9e5ea86d721e49d6da39a544ffb869667..9e8568610462b2111ed3d4a06d2d3bb762f53f78 100644
--- a/apps/encryption/tests/Users/SetupTest.php
+++ b/apps/encryption/tests/Users/SetupTest.php
@@ -27,6 +27,7 @@ namespace OCA\Encryption\Tests\Users;
 
 
 use OCA\Encryption\Users\Setup;
+use OCP\ILogger;
 use Test\TestCase;
 
 class SetupTest extends TestCase {
@@ -45,7 +46,7 @@ class SetupTest extends TestCase {
 
 	protected function setUp() {
 		parent::setUp();
-		$logMock = $this->getMock('OCP\ILogger');
+		$logMock = $this->createMock(ILogger::class);
 		$userSessionMock = $this->getMockBuilder('OCP\IUserSession')
 			->disableOriginalConstructor()
 			->getMock();
diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php
index 84a9ad493d7c01e77120d2f2fb3902563c947f29..d2f1d40e16d39dbf25f9009d1306cd1df9b8b44e 100644
--- a/apps/encryption/tests/UtilTest.php
+++ b/apps/encryption/tests/UtilTest.php
@@ -26,7 +26,12 @@
 namespace OCA\Encryption\Tests;
 
 
+use OC\Files\View;
 use OCA\Encryption\Util;
+use OCP\Files\Mount\IMountPoint;
+use OCP\IConfig;
+use OCP\ILogger;
+use OCP\IUserManager;
 use Test\TestCase;
 
 class UtilTest extends TestCase {
@@ -70,16 +75,16 @@ class UtilTest extends TestCase {
 
 	protected function setUp() {
 		parent::setUp();
-		$this->mountMock = $this->getMock('\OCP\Files\Mount\IMountPoint');
-		$this->filesMock = $this->getMock('OC\Files\View');
-		$this->userManagerMock = $this->getMock('\OCP\IUserManager');
+		$this->mountMock = $this->createMock(IMountPoint::class);
+		$this->filesMock = $this->createMock(View::class);
+		$this->userManagerMock = $this->createMock(IUserManager::class);
 
 		/** @var \OCA\Encryption\Crypto\Crypt $cryptMock */
 		$cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')
 			->disableOriginalConstructor()
 			->getMock();
 		/** @var \OCP\ILogger $loggerMock */
-		$loggerMock = $this->getMock('OCP\ILogger');
+		$loggerMock = $this->createMock(ILogger::class);
 		/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */
 		$userSessionMock = $this->getMockBuilder('OCP\IUserSession')
 			->disableOriginalConstructor()
@@ -102,7 +107,7 @@ class UtilTest extends TestCase {
 			->will($this->returnSelf());
 
 
-		$this->configMock = $this->getMock('OCP\IConfig');
+		$this->configMock = $this->createMock(IConfig::class);
 
 		$this->configMock->expects($this->any())
 			->method('getUserValue')