Fix getMock encryption
This commit is contained in:
parent
831179971c
commit
0c154c1ed7
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue