diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-10-26 13:46:16 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-10-26 13:56:56 +0200 |
commit | c733cdaa65ea473b848fb8329674145f54c1277b (patch) | |
tree | fa1bebe361ee81a1c3e8ead10263af65610f6d97 /apps/encryption/tests | |
parent | 06f46bd25614c080b75558e8372124142906d977 (diff) | |
download | nextcloud-server-c733cdaa65ea473b848fb8329674145f54c1277b.tar.gz nextcloud-server-c733cdaa65ea473b848fb8329674145f54c1277b.zip |
Use ::class in test mocks of encryption app
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r-- | apps/encryption/tests/Command/TestEnableMasterKey.php | 11 | ||||
-rw-r--r-- | apps/encryption/tests/Controller/RecoveryControllerTest.php | 3 | ||||
-rw-r--r-- | apps/encryption/tests/Controller/SettingsControllerTest.php | 17 | ||||
-rw-r--r-- | apps/encryption/tests/Controller/StatusControllerTest.php | 2 | ||||
-rw-r--r-- | apps/encryption/tests/Crypto/CryptTest.php | 5 | ||||
-rw-r--r-- | apps/encryption/tests/Crypto/DecryptAllTest.php | 10 | ||||
-rw-r--r-- | apps/encryption/tests/Crypto/EncryptAllTest.php | 37 | ||||
-rw-r--r-- | apps/encryption/tests/Crypto/EncryptionTest.php | 21 | ||||
-rw-r--r-- | apps/encryption/tests/HookManagerTest.php | 7 | ||||
-rw-r--r-- | apps/encryption/tests/Hooks/UserHooksTest.php | 30 | ||||
-rw-r--r-- | apps/encryption/tests/KeyManagerTest.php | 32 | ||||
-rw-r--r-- | apps/encryption/tests/RecoveryTest.php | 9 | ||||
-rw-r--r-- | apps/encryption/tests/Users/SetupTest.php | 9 | ||||
-rw-r--r-- | apps/encryption/tests/UtilTest.php | 9 |
14 files changed, 125 insertions, 77 deletions
diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php index dac26c5d3c7..58118db8c53 100644 --- a/apps/encryption/tests/Command/TestEnableMasterKey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -28,6 +28,9 @@ namespace OCA\Encryption\Tests\Command; use OCA\Encryption\Command\EnableMasterKey; use OCA\Encryption\Util; use OCP\IConfig; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; class TestEnableMasterKey extends TestCase { @@ -53,15 +56,15 @@ class TestEnableMasterKey extends TestCase { public function setUp() { parent::setUp(); - $this->util = $this->getMockBuilder('OCA\Encryption\Util') + $this->util = $this->getMockBuilder(Util::class) ->disableOriginalConstructor()->getMock(); $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); - $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') + $this->questionHelper = $this->getMockBuilder(QuestionHelper::class) ->disableOriginalConstructor()->getMock(); - $this->output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $this->output = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor()->getMock(); - $this->input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $this->input = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor()->getMock(); $this->enableMasterKey = new EnableMasterKey($this->util, $this->config, $this->questionHelper); diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php index 384cce94c42..7ab3bc7eebb 100644 --- a/apps/encryption/tests/Controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\RecoveryController; +use OCA\Encryption\Recovery; use OCP\AppFramework\Http; use OCP\IConfig; use OCP\IL10N; @@ -171,7 +172,7 @@ class RecoveryControllerTest extends TestCase { ->method('t') ->willReturnArgument(0); - $this->recoveryMock = $this->getMockBuilder('OCA\Encryption\Recovery') + $this->recoveryMock = $this->getMockBuilder(Recovery::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php index fcff78d77de..aceb94b23f7 100644 --- a/apps/encryption/tests/Controller/SettingsControllerTest.php +++ b/apps/encryption/tests/Controller/SettingsControllerTest.php @@ -24,11 +24,16 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\SettingsController; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\KeyManager; use OCA\Encryption\Session; +use OCA\Encryption\Util; use OCP\AppFramework\Http; use OCP\IL10N; use OCP\IRequest; +use OCP\ISession; use OCP\IUserManager; +use OCP\IUserSession; use Test\TestCase; class SettingsControllerTest extends TestCase { @@ -81,13 +86,13 @@ class SettingsControllerTest extends TestCase { $this->userManagerMock = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor()->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor()->getMock(); - $this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $this->userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -100,7 +105,7 @@ class SettingsControllerTest extends TestCase { ]) ->getMock(); - $this->ocSessionMock = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); + $this->ocSessionMock = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock(); $this->userSessionMock->expects($this->any()) ->method('getUID') @@ -110,10 +115,10 @@ class SettingsControllerTest extends TestCase { ->method($this->anything()) ->will($this->returnSelf()); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); - $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $this->utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php index cd3a8fdaa72..d72fcd1ac36 100644 --- a/apps/encryption/tests/Controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -53,7 +53,7 @@ class StatusControllerTest extends TestCase { parent::setUp(); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); $this->requestMock = $this->createMock(IRequest::class); diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index 4800be0a5ed..ace4453a803 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -30,6 +30,7 @@ use OCA\Encryption\Crypto\Crypt; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; +use OCP\IUserSession; use Test\TestCase; class CryptTest extends TestCase { @@ -59,7 +60,7 @@ class CryptTest extends TestCase { $this->logger->expects($this->any()) ->method('warning') ->willReturn(true); - $this->userSession = $this->getMockBuilder('OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); $this->config = $this->getMockBuilder(IConfig::class) @@ -391,7 +392,7 @@ class CryptTest extends TestCase { */ public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected) { /** @var \OCA\Encryption\Crypto\Crypt | \PHPUnit_Framework_MockObject_MockObject $crypt */ - $crypt = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $crypt = $this->getMockBuilder(Crypt::class) ->setConstructorArgs( [ $this->logger, diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php index fdef37adc84..99b1b47ba8e 100644 --- a/apps/encryption/tests/Crypto/DecryptAllTest.php +++ b/apps/encryption/tests/Crypto/DecryptAllTest.php @@ -56,15 +56,15 @@ class DecryptAllTest extends TestCase { public function setUp() { parent::setUp(); - $this->util = $this->getMockBuilder('OCA\Encryption\Util') + $this->util = $this->getMockBuilder(Util::class) ->disableOriginalConstructor()->getMock(); - $this->keyManager = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManager = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor()->getMock(); - $this->crypt = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->crypt = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor()->getMock(); - $this->session = $this->getMockBuilder('OCA\Encryption\Session') + $this->session = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); - $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') + $this->questionHelper = $this->getMockBuilder(QuestionHelper::class) ->disableOriginalConstructor()->getMock(); $this->instance = new DecryptAll( diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index 7d432a6d524..38b64a8b6bf 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -25,13 +25,22 @@ namespace OCA\Encryption\Tests\Crypto; +use OC\Files\View; use OCA\Encryption\Crypto\EncryptAll; +use OCA\Encryption\KeyManager; +use OCA\Encryption\Users\Setup; +use OCA\Encryption\Util; use OCP\IConfig; use OCP\IL10N; use OCP\IUserManager; use OCP\Mail\IMailer; +use OCP\Security\ISecureRandom; use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; class EncryptAllTest extends TestCase { @@ -80,15 +89,15 @@ class EncryptAllTest extends TestCase { function setUp() { parent::setUp(); - $this->setupUser = $this->getMockBuilder('OCA\Encryption\Users\Setup') + $this->setupUser = $this->getMockBuilder(Setup::class) ->disableOriginalConstructor()->getMock(); - $this->keyManager = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManager = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor()->getMock(); - $this->util = $this->getMockBuilder('OCA\Encryption\Util') + $this->util = $this->getMockBuilder(Util::class) ->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->view = $this->getMockBuilder('OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); @@ -96,11 +105,11 @@ class EncryptAllTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); - $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') + $this->questionHelper = $this->getMockBuilder(QuestionHelper::class) ->disableOriginalConstructor()->getMock(); - $this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $this->inputInterface = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor()->getMock(); - $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $this->outputInterface = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor()->getMock(); $this->userInterface = $this->getMockBuilder(UserInterface::class) ->disableOriginalConstructor()->getMock(); @@ -112,7 +121,7 @@ class EncryptAllTest extends TestCase { $this->userManager->expects($this->any())->method('getBackends')->willReturn([$this->userInterface]); $this->userInterface->expects($this->any())->method('getUsers')->willReturn(['user1', 'user2']); - $this->secureRandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->disableOriginalConstructor()->getMock(); + $this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->disableOriginalConstructor()->getMock(); $this->secureRandom->expects($this->any())->method('getMediumStrengthGenerator')->willReturn($this->secureRandom); $this->secureRandom->expects($this->any())->method('getLowStrengthGenerator')->willReturn($this->secureRandom); $this->secureRandom->expects($this->any())->method('generate')->willReturn('12345678'); @@ -134,7 +143,7 @@ class EncryptAllTest extends TestCase { public function testEncryptAll() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -163,7 +172,7 @@ class EncryptAllTest extends TestCase { public function testEncryptAllWithMasterKey() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -193,7 +202,7 @@ class EncryptAllTest extends TestCase { public function testCreateKeyPairs() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -242,7 +251,7 @@ class EncryptAllTest extends TestCase { public function testEncryptAllUsersFiles() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -275,7 +284,7 @@ class EncryptAllTest extends TestCase { public function testEncryptUsersFiles() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -323,7 +332,7 @@ class EncryptAllTest extends TestCase { $encryptAll->expects($this->at(1))->method('encryptFile')->with('/user1/files/bar'); $encryptAll->expects($this->at(2))->method('encryptFile')->with('/user1/files/foo/subfile'); - $progressBar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar') + $progressBar = $this->getMockBuilder(ProgressBar::class) ->disableOriginalConstructor()->getMock(); $this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 3bd4593d6bc..42da71b0eb1 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -23,7 +23,14 @@ namespace OCA\Encryption\Tests\Crypto; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\Crypto\DecryptAll; +use OCA\Encryption\Crypto\EncryptAll; use OCA\Encryption\Exceptions\PublicKeyMissingException; +use OCA\Encryption\KeyManager; +use OCA\Encryption\Session; +use OCA\Encryption\Util; +use OCP\Files\Storage; use OCP\IL10N; use OCP\ILogger; use Symfony\Component\Console\Input\InputInterface; @@ -66,24 +73,24 @@ class EncryptionTest extends TestCase { public function setUp() { parent::setUp(); - $this->storageMock = $this->getMockBuilder('OCP\Files\Storage') + $this->storageMock = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor()->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); - $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $this->utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); - $this->encryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $this->encryptAllMock = $this->getMockBuilder(EncryptAll::class) ->disableOriginalConstructor() ->getMock(); - $this->decryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\DecryptAll') + $this->decryptAllMock = $this->getMockBuilder(DecryptAll::class) ->disableOriginalConstructor() ->getMock(); $this->loggerMock = $this->getMockBuilder(ILogger::class) diff --git a/apps/encryption/tests/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php index c5e5487dba5..109afb1ef8d 100644 --- a/apps/encryption/tests/HookManagerTest.php +++ b/apps/encryption/tests/HookManagerTest.php @@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests; use OCA\Encryption\HookManager; +use OCA\Encryption\Hooks\Contracts\IHook; use OCP\IConfig; use Test\TestCase; @@ -41,8 +42,8 @@ class HookManagerTest extends TestCase { */ public function testRegisterHookWithArray() { self::$instance->registerHook([ - $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(), - $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(), + $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(), + $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(), $this->createMock(IConfig::class) ]); @@ -66,7 +67,7 @@ class HookManagerTest extends TestCase { * */ public function testRegisterHooksWithInstance() { - $mock = $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(); + $mock = $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(); /** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */ self::$instance->registerHook($mock); diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index 506f46eb8e6..f4c7a5ae0f7 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -29,9 +29,15 @@ namespace OCA\Encryption\Tests\Hooks; use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Hooks\UserHooks; +use OCA\Encryption\KeyManager; +use OCA\Encryption\Recovery; +use OCA\Encryption\Session; +use OCA\Encryption\Users\Setup; +use OCA\Encryption\Util; use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use OCP\IUserSession; use Test\TestCase; /** @@ -152,7 +158,7 @@ class UserHooksTest extends TestCase { public function testPreSetPassphrase($canChange) { /** @var UserHooks | \PHPUnit_Framework_MockObject_MockObject $instance */ - $instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $instance = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, @@ -231,7 +237,7 @@ class UserHooksTest extends TestCase { ->willReturnOnConsecutiveCalls(true, false); - $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $this->instance = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, @@ -292,7 +298,7 @@ class UserHooksTest extends TestCase { ->method('getPrivateKey') ->willReturn(true); - $userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); @@ -303,7 +309,7 @@ class UserHooksTest extends TestCase { ->with('testUser') ->willReturn(false); - $userHooks = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $userHooks = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, @@ -325,17 +331,17 @@ class UserHooksTest extends TestCase { protected function setUp() { parent::setUp(); $this->loggerMock = $this->createMock(ILogger::class); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor() ->getMock(); $this->userManagerMock = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSetupMock = $this->getMockBuilder('OCA\Encryption\Users\Setup') + $this->userSetupMock = $this->getMockBuilder(Setup::class) ->disableOriginalConstructor() ->getMock(); - $this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $this->userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -354,18 +360,18 @@ class UserHooksTest extends TestCase { ->method($this->anything()) ->will($this->returnSelf()); - $utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); - $sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); - $recoveryMock = $this->getMockBuilder('OCA\Encryption\Recovery') + $recoveryMock = $this->getMockBuilder(Recovery::class) ->disableOriginalConstructor() ->getMock(); @@ -374,7 +380,7 @@ class UserHooksTest extends TestCase { $this->utilMock = $utilMock; $this->utilMock->expects($this->any())->method('isMasterKeyEnabled')->willReturn(false); - $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $this->instance = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index a8441427a2c..721b7f53a0c 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -27,9 +27,15 @@ namespace OCA\Encryption\Tests; +use OC\Files\FileInfo; +use OC\Files\View; +use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\KeyManager; use OCA\Encryption\Session; +use OCA\Encryption\Util; use OCP\Encryption\Keys\IStorage; +use OCP\Files\Cache\ICache; +use OCP\Files\Storage; use OCP\IConfig; use OCP\ILogger; use OCP\IUserSession; @@ -74,7 +80,7 @@ class KeyManagerTest extends TestCase { $this->userId = 'user1'; $this->systemKeyId = 'systemKeyId'; $this->keyStorageMock = $this->createMock(IStorage::class); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); $this->configMock = $this->createMock(IConfig::class); @@ -82,11 +88,11 @@ class KeyManagerTest extends TestCase { ->method('getAppValue') ->willReturn($this->systemKeyId); $this->userMock = $this->createMock(IUserSession::class); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); $this->logMock = $this->createMock(ILogger::class); - $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $this->utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); @@ -251,7 +257,7 @@ class KeyManagerTest extends TestCase { public function testInit($useMasterKey) { /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */ - $instance = $this->getMockBuilder('OCA\Encryption\KeyManager') + $instance = $this->getMockBuilder(KeyManager::class) ->setConstructorArgs( [ $this->keyStorageMock, @@ -544,7 +550,7 @@ class KeyManagerTest extends TestCase { public function testValidateMasterKey($masterKey) { /** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */ - $instance = $this->getMockBuilder('OCA\Encryption\KeyManager') + $instance = $this->getMockBuilder(KeyManager::class) ->setConstructorArgs( [ $this->keyStorageMock, @@ -592,7 +598,7 @@ class KeyManagerTest extends TestCase { } public function testGetVersionWithoutFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $view->expects($this->once()) ->method('getFileInfo') @@ -604,9 +610,9 @@ class KeyManagerTest extends TestCase { } public function testGetVersionWithFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); - $fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo') + $fileInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $fileInfo->expects($this->once()) ->method('getEncryptedVersion') @@ -621,19 +627,19 @@ class KeyManagerTest extends TestCase { } public function testSetVersionWithFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); - $cache = $this->getMockBuilder('\\OCP\\Files\\Cache\\ICache') + $cache = $this->getMockBuilder(ICache::class) ->disableOriginalConstructor()->getMock(); $cache->expects($this->once()) ->method('update') ->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]); - $storage = $this->getMockBuilder('\\OCP\\Files\\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor()->getMock(); $storage->expects($this->once()) ->method('getCache') ->willReturn($cache); - $fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo') + $fileInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $fileInfo->expects($this->once()) ->method('getStorage') @@ -651,7 +657,7 @@ class KeyManagerTest extends TestCase { } public function testSetVersionWithoutFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $view->expects($this->once()) ->method('getFileInfo') diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php index d73b5d48c91..2dda774565c 100644 --- a/apps/encryption/tests/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -28,10 +28,13 @@ namespace OCA\Encryption\Tests; use OC\Files\View; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\KeyManager; use OCA\Encryption\Recovery; use OCP\Encryption\IFile; use OCP\Encryption\Keys\IStorage; use OCP\IConfig; +use OCP\IUserSession; use OCP\Security\ISecureRandom; use Test\TestCase; @@ -253,7 +256,7 @@ class RecoveryTest extends TestCase { parent::setUp(); - $this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $this->userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -271,10 +274,10 @@ class RecoveryTest extends TestCase { ->method($this->anything()) ->will($this->returnSelf()); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock(); + $this->cryptMock = $this->getMockBuilder(Crypt::class)->disableOriginalConstructor()->getMock(); /** @var \OCP\Security\ISecureRandom $randomMock */ $randomMock = $this->createMock(ISecureRandom::class); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock(); + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)->disableOriginalConstructor()->getMock(); $this->configMock = $this->createMock(IConfig::class); /** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */ $keyStorageMock = $this->createMock(IStorage::class); diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php index 9e856861046..27866ef3927 100644 --- a/apps/encryption/tests/Users/SetupTest.php +++ b/apps/encryption/tests/Users/SetupTest.php @@ -26,8 +26,11 @@ namespace OCA\Encryption\Tests\Users; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\KeyManager; use OCA\Encryption\Users\Setup; use OCP\ILogger; +use OCP\IUserSession; use Test\TestCase; class SetupTest extends TestCase { @@ -47,14 +50,14 @@ class SetupTest extends TestCase { protected function setUp() { parent::setUp(); $logMock = $this->createMock(ILogger::class); - $userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php index 40fc5537251..e59565d3b84 100644 --- a/apps/encryption/tests/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -27,11 +27,14 @@ namespace OCA\Encryption\Tests; use OC\Files\View; +use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Util; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Storage; use OCP\IConfig; use OCP\ILogger; use OCP\IUserManager; +use OCP\IUserSession; use Test\TestCase; class UtilTest extends TestCase { @@ -80,13 +83,13 @@ class UtilTest extends TestCase { $this->userManagerMock = $this->createMock(IUserManager::class); /** @var \OCA\Encryption\Crypto\Crypt $cryptMock */ - $cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); /** @var \OCP\ILogger $loggerMock */ $loggerMock = $this->createMock(ILogger::class); /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */ - $userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -205,7 +208,7 @@ class UtilTest extends TestCase { } public function testGetStorage() { - $return = $this->getMockBuilder('OC\Files\Storage\Storage') + $return = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); |