aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-09-02 10:29:05 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-09-06 09:29:27 +0200
commit0c154c1ed779ccd68ea67e3528fad36ad6ac9b34 (patch)
tree05a9f0d94c8730ed6de352b91a8db72c72ca957f
parent831179971cf2d693cc09e4a216387d107567a47e (diff)
downloadnextcloud-server-0c154c1ed779ccd68ea67e3528fad36ad6ac9b34.tar.gz
nextcloud-server-0c154c1ed779ccd68ea67e3528fad36ad6ac9b34.zip
Fix getMock encryption
-rw-r--r--apps/encryption/tests/Controller/SettingsControllerTest.php3
-rw-r--r--apps/encryption/tests/Controller/StatusControllerTest.php3
-rw-r--r--apps/encryption/tests/Crypto/CryptTest.php3
-rw-r--r--apps/encryption/tests/Crypto/EncryptAllTest.php3
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php6
-rw-r--r--apps/encryption/tests/Hooks/UserHooksTest.php6
-rw-r--r--apps/encryption/tests/KeyManagerTest.php12
-rw-r--r--apps/encryption/tests/MigrationTest.php6
-rw-r--r--apps/encryption/tests/RecoveryTest.php15
-rw-r--r--apps/encryption/tests/SessionTest.php3
-rw-r--r--apps/encryption/tests/Users/SetupTest.php3
-rw-r--r--apps/encryption/tests/UtilTest.php15
12 files changed, 54 insertions, 24 deletions
diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php
index 5661ab7033f..4f3e09687e3 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 17cec468438..c6c92e2aac2 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 7bd06471b53..b808acaf199 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 8232af5f9f2..6c279a54f57 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 4d8b6bbbf2f..658f6275bb4 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 6ccca3d2afa..43cc54f8901 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 9ac3befdfcb..fec311afa35 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 3126dd2ff2c..0aea7543c2c 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 477913a1a69..d73b5d48c91 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 1a22726f5b1..099acddbca1 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 252092f9e5e..9e856861046 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 84a9ad493d7..d2f1d40e16d 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')