Merge pull request #6970 from nextcloud/class-usage-in-mocks-encryption-app

Use ::class in test mocks of encryption app
This commit is contained in:
Morris Jobke 2017-10-26 16:02:01 +02:00 committed by GitHub
commit c25b694fca
27 changed files with 176 additions and 115 deletions

View File

@ -28,6 +28,9 @@ namespace OCA\Encryption\Tests\Command;
use OCA\Encryption\Command\EnableMasterKey; use OCA\Encryption\Command\EnableMasterKey;
use OCA\Encryption\Util; use OCA\Encryption\Util;
use OCP\IConfig; use OCP\IConfig;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase; use Test\TestCase;
class TestEnableMasterKey extends TestCase { class TestEnableMasterKey extends TestCase {
@ -53,15 +56,15 @@ class TestEnableMasterKey extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->util = $this->getMockBuilder('OCA\Encryption\Util') $this->util = $this->getMockBuilder(Util::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->config = $this->getMockBuilder(IConfig::class) $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') $this->questionHelper = $this->getMockBuilder(QuestionHelper::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') $this->output = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') $this->input = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->enableMasterKey = new EnableMasterKey($this->util, $this->config, $this->questionHelper); $this->enableMasterKey = new EnableMasterKey($this->util, $this->config, $this->questionHelper);

View File

@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests\Controller;
use OCA\Encryption\Controller\RecoveryController; use OCA\Encryption\Controller\RecoveryController;
use OCA\Encryption\Recovery;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
@ -171,7 +172,7 @@ class RecoveryControllerTest extends TestCase {
->method('t') ->method('t')
->willReturnArgument(0); ->willReturnArgument(0);
$this->recoveryMock = $this->getMockBuilder('OCA\Encryption\Recovery') $this->recoveryMock = $this->getMockBuilder(Recovery::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -24,11 +24,16 @@
namespace OCA\Encryption\Tests\Controller; namespace OCA\Encryption\Tests\Controller;
use OCA\Encryption\Controller\SettingsController; use OCA\Encryption\Controller\SettingsController;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session; use OCA\Encryption\Session;
use OCA\Encryption\Util;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;
use OCP\ISession;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession;
use Test\TestCase; use Test\TestCase;
class SettingsControllerTest extends TestCase { class SettingsControllerTest extends TestCase {
@ -81,13 +86,13 @@ class SettingsControllerTest extends TestCase {
$this->userManagerMock = $this->getMockBuilder(IUserManager::class) $this->userManagerMock = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') $this->userSessionMock = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods([ ->setMethods([
'isLoggedIn', 'isLoggedIn',
@ -100,7 +105,7 @@ class SettingsControllerTest extends TestCase {
]) ])
->getMock(); ->getMock();
$this->ocSessionMock = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); $this->ocSessionMock = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock();
$this->userSessionMock->expects($this->any()) $this->userSessionMock->expects($this->any())
->method('getUID') ->method('getUID')
@ -110,10 +115,10 @@ class SettingsControllerTest extends TestCase {
->method($this->anything()) ->method($this->anything())
->will($this->returnSelf()); ->will($this->returnSelf());
$this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') $this->sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') $this->utilMock = $this->getMockBuilder(Util::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -53,7 +53,7 @@ class StatusControllerTest extends TestCase {
parent::setUp(); parent::setUp();
$this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') $this->sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->requestMock = $this->createMock(IRequest::class); $this->requestMock = $this->createMock(IRequest::class);

View File

@ -30,6 +30,7 @@ use OCA\Encryption\Crypto\Crypt;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserSession;
use Test\TestCase; use Test\TestCase;
class CryptTest extends TestCase { class CryptTest extends TestCase {
@ -59,7 +60,7 @@ class CryptTest extends TestCase {
$this->logger->expects($this->any()) $this->logger->expects($this->any())
->method('warning') ->method('warning')
->willReturn(true); ->willReturn(true);
$this->userSession = $this->getMockBuilder('OCP\IUserSession') $this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->config = $this->getMockBuilder(IConfig::class) $this->config = $this->getMockBuilder(IConfig::class)
@ -391,7 +392,7 @@ class CryptTest extends TestCase {
*/ */
public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected) { public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected) {
/** @var \OCA\Encryption\Crypto\Crypt | \PHPUnit_Framework_MockObject_MockObject $crypt */ /** @var \OCA\Encryption\Crypto\Crypt | \PHPUnit_Framework_MockObject_MockObject $crypt */
$crypt = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $crypt = $this->getMockBuilder(Crypt::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->logger, $this->logger,

View File

@ -56,15 +56,15 @@ class DecryptAllTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->util = $this->getMockBuilder('OCA\Encryption\Util') $this->util = $this->getMockBuilder(Util::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->keyManager = $this->getMockBuilder('OCA\Encryption\KeyManager') $this->keyManager = $this->getMockBuilder(KeyManager::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->crypt = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $this->crypt = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->session = $this->getMockBuilder('OCA\Encryption\Session') $this->session = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') $this->questionHelper = $this->getMockBuilder(QuestionHelper::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->instance = new DecryptAll( $this->instance = new DecryptAll(

View File

@ -25,13 +25,22 @@
namespace OCA\Encryption\Tests\Crypto; namespace OCA\Encryption\Tests\Crypto;
use OC\Files\View;
use OCA\Encryption\Crypto\EncryptAll; use OCA\Encryption\Crypto\EncryptAll;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Mail\IMailer; use OCP\Mail\IMailer;
use OCP\Security\ISecureRandom;
use OCP\UserInterface; use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface; 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; use Test\TestCase;
class EncryptAllTest extends TestCase { class EncryptAllTest extends TestCase {
@ -80,15 +89,15 @@ class EncryptAllTest extends TestCase {
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->setupUser = $this->getMockBuilder('OCA\Encryption\Users\Setup') $this->setupUser = $this->getMockBuilder(Setup::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->keyManager = $this->getMockBuilder('OCA\Encryption\KeyManager') $this->keyManager = $this->getMockBuilder(KeyManager::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->util = $this->getMockBuilder('OCA\Encryption\Util') $this->util = $this->getMockBuilder(Util::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->userManager = $this->getMockBuilder(IUserManager::class) $this->userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->view = $this->getMockBuilder('OC\Files\View') $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->config = $this->getMockBuilder(IConfig::class) $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
@ -96,11 +105,11 @@ class EncryptAllTest extends TestCase {
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->l = $this->getMockBuilder(IL10N::class) $this->l = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') $this->questionHelper = $this->getMockBuilder(QuestionHelper::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') $this->inputInterface = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') $this->outputInterface = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->userInterface = $this->getMockBuilder(UserInterface::class) $this->userInterface = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
@ -112,7 +121,7 @@ class EncryptAllTest extends TestCase {
$this->userManager->expects($this->any())->method('getBackends')->willReturn([$this->userInterface]); $this->userManager->expects($this->any())->method('getBackends')->willReturn([$this->userInterface]);
$this->userInterface->expects($this->any())->method('getUsers')->willReturn(['user1', 'user2']); $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('getMediumStrengthGenerator')->willReturn($this->secureRandom);
$this->secureRandom->expects($this->any())->method('getLowStrengthGenerator')->willReturn($this->secureRandom); $this->secureRandom->expects($this->any())->method('getLowStrengthGenerator')->willReturn($this->secureRandom);
$this->secureRandom->expects($this->any())->method('generate')->willReturn('12345678'); $this->secureRandom->expects($this->any())->method('generate')->willReturn('12345678');
@ -134,7 +143,7 @@ class EncryptAllTest extends TestCase {
public function testEncryptAll() { public function testEncryptAll() {
/** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */
$encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') $encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->setupUser, $this->setupUser,
@ -163,7 +172,7 @@ class EncryptAllTest extends TestCase {
public function testEncryptAllWithMasterKey() { public function testEncryptAllWithMasterKey() {
/** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */
$encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') $encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->setupUser, $this->setupUser,
@ -193,7 +202,7 @@ class EncryptAllTest extends TestCase {
public function testCreateKeyPairs() { public function testCreateKeyPairs() {
/** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */
$encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') $encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->setupUser, $this->setupUser,
@ -242,7 +251,7 @@ class EncryptAllTest extends TestCase {
public function testEncryptAllUsersFiles() { public function testEncryptAllUsersFiles() {
/** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */
$encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') $encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->setupUser, $this->setupUser,
@ -275,7 +284,7 @@ class EncryptAllTest extends TestCase {
public function testEncryptUsersFiles() { public function testEncryptUsersFiles() {
/** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */
$encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') $encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->setupUser, $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(1))->method('encryptFile')->with('/user1/files/bar');
$encryptAll->expects($this->at(2))->method('encryptFile')->with('/user1/files/foo/subfile'); $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(); ->disableOriginalConstructor()->getMock();
$this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']); $this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']);

View File

@ -23,7 +23,14 @@
namespace OCA\Encryption\Tests\Crypto; 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\Exceptions\PublicKeyMissingException;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session;
use OCA\Encryption\Util;
use OCP\Files\Storage;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -66,24 +73,24 @@ class EncryptionTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->storageMock = $this->getMockBuilder('OCP\Files\Storage') $this->storageMock = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') $this->utilMock = $this->getMockBuilder(Util::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') $this->sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->encryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') $this->encryptAllMock = $this->getMockBuilder(EncryptAll::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->decryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\DecryptAll') $this->decryptAllMock = $this->getMockBuilder(DecryptAll::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->loggerMock = $this->getMockBuilder(ILogger::class) $this->loggerMock = $this->getMockBuilder(ILogger::class)

View File

@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests;
use OCA\Encryption\HookManager; use OCA\Encryption\HookManager;
use OCA\Encryption\Hooks\Contracts\IHook;
use OCP\IConfig; use OCP\IConfig;
use Test\TestCase; use Test\TestCase;
@ -41,8 +42,8 @@ class HookManagerTest extends TestCase {
*/ */
public function testRegisterHookWithArray() { public function testRegisterHookWithArray() {
self::$instance->registerHook([ self::$instance->registerHook([
$this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(), $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(),
$this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(), $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(),
$this->createMock(IConfig::class) $this->createMock(IConfig::class)
]); ]);
@ -66,7 +67,7 @@ class HookManagerTest extends TestCase {
* *
*/ */
public function testRegisterHooksWithInstance() { 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 */ /** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */
self::$instance->registerHook($mock); self::$instance->registerHook($mock);

View File

@ -29,9 +29,15 @@ namespace OCA\Encryption\Tests\Hooks;
use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Hooks\UserHooks; 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\ILogger;
use OCP\IUser; use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession;
use Test\TestCase; use Test\TestCase;
/** /**
@ -152,7 +158,7 @@ class UserHooksTest extends TestCase {
public function testPreSetPassphrase($canChange) { public function testPreSetPassphrase($canChange) {
/** @var UserHooks | \PHPUnit_Framework_MockObject_MockObject $instance */ /** @var UserHooks | \PHPUnit_Framework_MockObject_MockObject $instance */
$instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') $instance = $this->getMockBuilder(UserHooks::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->keyManagerMock, $this->keyManagerMock,
@ -231,7 +237,7 @@ class UserHooksTest extends TestCase {
->willReturnOnConsecutiveCalls(true, false); ->willReturnOnConsecutiveCalls(true, false);
$this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') $this->instance = $this->getMockBuilder(UserHooks::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->keyManagerMock, $this->keyManagerMock,
@ -292,7 +298,7 @@ class UserHooksTest extends TestCase {
->method('getPrivateKey') ->method('getPrivateKey')
->willReturn(true); ->willReturn(true);
$userSessionMock = $this->getMockBuilder('OCP\IUserSession') $userSessionMock = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -303,7 +309,7 @@ class UserHooksTest extends TestCase {
->with('testUser') ->with('testUser')
->willReturn(false); ->willReturn(false);
$userHooks = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') $userHooks = $this->getMockBuilder(UserHooks::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->keyManagerMock, $this->keyManagerMock,
@ -325,17 +331,17 @@ class UserHooksTest extends TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->loggerMock = $this->createMock(ILogger::class); $this->loggerMock = $this->createMock(ILogger::class);
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->userManagerMock = $this->getMockBuilder(IUserManager::class) $this->userManagerMock = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->userSetupMock = $this->getMockBuilder('OCA\Encryption\Users\Setup') $this->userSetupMock = $this->getMockBuilder(Setup::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') $this->userSessionMock = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods([ ->setMethods([
'isLoggedIn', 'isLoggedIn',
@ -354,18 +360,18 @@ class UserHooksTest extends TestCase {
->method($this->anything()) ->method($this->anything())
->will($this->returnSelf()); ->will($this->returnSelf());
$utilMock = $this->getMockBuilder('OCA\Encryption\Util') $utilMock = $this->getMockBuilder(Util::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$sessionMock = $this->getMockBuilder('OCA\Encryption\Session') $sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$recoveryMock = $this->getMockBuilder('OCA\Encryption\Recovery') $recoveryMock = $this->getMockBuilder(Recovery::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -374,7 +380,7 @@ class UserHooksTest extends TestCase {
$this->utilMock = $utilMock; $this->utilMock = $utilMock;
$this->utilMock->expects($this->any())->method('isMasterKeyEnabled')->willReturn(false); $this->utilMock->expects($this->any())->method('isMasterKeyEnabled')->willReturn(false);
$this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') $this->instance = $this->getMockBuilder(UserHooks::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->keyManagerMock, $this->keyManagerMock,

View File

@ -27,9 +27,15 @@
namespace OCA\Encryption\Tests; namespace OCA\Encryption\Tests;
use OC\Files\FileInfo;
use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager; use OCA\Encryption\KeyManager;
use OCA\Encryption\Session; use OCA\Encryption\Session;
use OCA\Encryption\Util;
use OCP\Encryption\Keys\IStorage; use OCP\Encryption\Keys\IStorage;
use OCP\Files\Cache\ICache;
use OCP\Files\Storage;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserSession; use OCP\IUserSession;
@ -74,7 +80,7 @@ class KeyManagerTest extends TestCase {
$this->userId = 'user1'; $this->userId = 'user1';
$this->systemKeyId = 'systemKeyId'; $this->systemKeyId = 'systemKeyId';
$this->keyStorageMock = $this->createMock(IStorage::class); $this->keyStorageMock = $this->createMock(IStorage::class);
$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->configMock = $this->createMock(IConfig::class); $this->configMock = $this->createMock(IConfig::class);
@ -82,11 +88,11 @@ class KeyManagerTest extends TestCase {
->method('getAppValue') ->method('getAppValue')
->willReturn($this->systemKeyId); ->willReturn($this->systemKeyId);
$this->userMock = $this->createMock(IUserSession::class); $this->userMock = $this->createMock(IUserSession::class);
$this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') $this->sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->logMock = $this->createMock(ILogger::class); $this->logMock = $this->createMock(ILogger::class);
$this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') $this->utilMock = $this->getMockBuilder(Util::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -251,7 +257,7 @@ class KeyManagerTest extends TestCase {
public function testInit($useMasterKey) { public function testInit($useMasterKey) {
/** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */ /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */
$instance = $this->getMockBuilder('OCA\Encryption\KeyManager') $instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->keyStorageMock, $this->keyStorageMock,
@ -544,7 +550,7 @@ class KeyManagerTest extends TestCase {
public function testValidateMasterKey($masterKey) { public function testValidateMasterKey($masterKey) {
/** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */ /** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */
$instance = $this->getMockBuilder('OCA\Encryption\KeyManager') $instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs( ->setConstructorArgs(
[ [
$this->keyStorageMock, $this->keyStorageMock,
@ -592,7 +598,7 @@ class KeyManagerTest extends TestCase {
} }
public function testGetVersionWithoutFileInfo() { public function testGetVersionWithoutFileInfo() {
$view = $this->getMockBuilder('\\OC\\Files\\View') $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$view->expects($this->once()) $view->expects($this->once())
->method('getFileInfo') ->method('getFileInfo')
@ -604,9 +610,9 @@ class KeyManagerTest extends TestCase {
} }
public function testGetVersionWithFileInfo() { public function testGetVersionWithFileInfo() {
$view = $this->getMockBuilder('\\OC\\Files\\View') $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo') $fileInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$fileInfo->expects($this->once()) $fileInfo->expects($this->once())
->method('getEncryptedVersion') ->method('getEncryptedVersion')
@ -621,19 +627,19 @@ class KeyManagerTest extends TestCase {
} }
public function testSetVersionWithFileInfo() { public function testSetVersionWithFileInfo() {
$view = $this->getMockBuilder('\\OC\\Files\\View') $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$cache = $this->getMockBuilder('\\OCP\\Files\\Cache\\ICache') $cache = $this->getMockBuilder(ICache::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$cache->expects($this->once()) $cache->expects($this->once())
->method('update') ->method('update')
->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]); ->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]);
$storage = $this->getMockBuilder('\\OCP\\Files\\Storage') $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$storage->expects($this->once()) $storage->expects($this->once())
->method('getCache') ->method('getCache')
->willReturn($cache); ->willReturn($cache);
$fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo') $fileInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$fileInfo->expects($this->once()) $fileInfo->expects($this->once())
->method('getStorage') ->method('getStorage')
@ -651,7 +657,7 @@ class KeyManagerTest extends TestCase {
} }
public function testSetVersionWithoutFileInfo() { public function testSetVersionWithoutFileInfo() {
$view = $this->getMockBuilder('\\OC\\Files\\View') $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$view->expects($this->once()) $view->expects($this->once())
->method('getFileInfo') ->method('getFileInfo')

View File

@ -28,10 +28,13 @@ namespace OCA\Encryption\Tests;
use OC\Files\View; use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Recovery; use OCA\Encryption\Recovery;
use OCP\Encryption\IFile; use OCP\Encryption\IFile;
use OCP\Encryption\Keys\IStorage; use OCP\Encryption\Keys\IStorage;
use OCP\IConfig; use OCP\IConfig;
use OCP\IUserSession;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
use Test\TestCase; use Test\TestCase;
@ -253,7 +256,7 @@ class RecoveryTest extends TestCase {
parent::setUp(); parent::setUp();
$this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') $this->userSessionMock = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods([ ->setMethods([
'isLoggedIn', 'isLoggedIn',
@ -271,10 +274,10 @@ class RecoveryTest extends TestCase {
->method($this->anything()) ->method($this->anything())
->will($this->returnSelf()); ->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 */ /** @var \OCP\Security\ISecureRandom $randomMock */
$randomMock = $this->createMock(ISecureRandom::class); $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); $this->configMock = $this->createMock(IConfig::class);
/** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */ /** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */
$keyStorageMock = $this->createMock(IStorage::class); $keyStorageMock = $this->createMock(IStorage::class);

View File

@ -26,8 +26,11 @@
namespace OCA\Encryption\Tests\Users; namespace OCA\Encryption\Tests\Users;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup; use OCA\Encryption\Users\Setup;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserSession;
use Test\TestCase; use Test\TestCase;
class SetupTest extends TestCase { class SetupTest extends TestCase {
@ -47,14 +50,14 @@ class SetupTest extends TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$logMock = $this->createMock(ILogger::class); $logMock = $this->createMock(ILogger::class);
$userSessionMock = $this->getMockBuilder('OCP\IUserSession') $userSessionMock = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -27,11 +27,14 @@ namespace OCA\Encryption\Tests;
use OC\Files\View; use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Util; use OCA\Encryption\Util;
use OCP\Files\Mount\IMountPoint; use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession;
use Test\TestCase; use Test\TestCase;
class UtilTest extends TestCase { class UtilTest extends TestCase {
@ -80,13 +83,13 @@ class UtilTest extends TestCase {
$this->userManagerMock = $this->createMock(IUserManager::class); $this->userManagerMock = $this->createMock(IUserManager::class);
/** @var \OCA\Encryption\Crypto\Crypt $cryptMock */ /** @var \OCA\Encryption\Crypto\Crypt $cryptMock */
$cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') $cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var \OCP\ILogger $loggerMock */ /** @var \OCP\ILogger $loggerMock */
$loggerMock = $this->createMock(ILogger::class); $loggerMock = $this->createMock(ILogger::class);
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */ /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */
$userSessionMock = $this->getMockBuilder('OCP\IUserSession') $userSessionMock = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods([ ->setMethods([
'isLoggedIn', 'isLoggedIn',
@ -205,7 +208,7 @@ class UtilTest extends TestCase {
} }
public function testGetStorage() { public function testGetStorage() {
$return = $this->getMockBuilder('OC\Files\Storage\Storage') $return = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -95,9 +95,9 @@ class MountPublicLinkControllerTest extends \Test\TestCase {
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock();
$this->userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock();
$this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager); $this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
$this->session = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); $this->session = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock();
$this->l10n = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); $this->l10n = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock();
$this->userSession = $this->getMockBuilder('OCP\IUserSession')->disableOriginalConstructor()->getMock(); $this->userSession = $this->getMockBuilder(IUserSession::class)->disableOriginalConstructor()->getMock();
$this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock(); $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock();
$this->cloudIdManager = new CloudIdManager(); $this->cloudIdManager = new CloudIdManager();

View File

@ -42,7 +42,7 @@ class TokenHandlerTest extends \Test\TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->secureRandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->getMock(); $this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->getMock();
$this->tokenHandler = new TokenHandler($this->secureRandom); $this->tokenHandler = new TokenHandler($this->secureRandom);
} }

View File

@ -27,6 +27,8 @@ namespace OCA\Files\Tests\Command;
use OC\Files\View; use OC\Files\View;
use OCA\Files\Command\DeleteOrphanedFiles; use OCA\Files\Command\DeleteOrphanedFiles;
use OCP\Files\StorageNotAvailableException; use OCP\Files\StorageNotAvailableException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase; use Test\TestCase;
/** /**
@ -87,10 +89,10 @@ class DeleteOrphanedFilesTest extends TestCase {
* Test clearing orphaned files * Test clearing orphaned files
*/ */
public function testClearFiles() { public function testClearFiles() {
$input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') $input = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') $output = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -22,6 +22,8 @@
namespace OCA\Files_Sharing\Tests\Command; namespace OCA\Files_Sharing\Tests\Command;
use OCA\Files_Sharing\Command\CleanupRemoteStorages; use OCA\Files_Sharing\Command\CleanupRemoteStorages;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase; use Test\TestCase;
/** /**
@ -158,10 +160,10 @@ class CleanupRemoteStoragesTest extends TestCase {
* Test cleanup of orphaned storages * Test cleanup of orphaned storages
*/ */
public function testCleanup() { public function testCleanup() {
$input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') $input = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') $output = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -264,7 +264,7 @@ class ShareAPIControllerTest extends TestCase {
->getMock(); ->getMock();
$cache->method('getNumericStorageId')->willReturn(101); $cache->method('getNumericStorageId')->willReturn(101);
$storage = $this->getMockBuilder('OC\Files\Storage\Storage') $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$storage->method('getId')->willReturn('STORAGE'); $storage->method('getId')->willReturn('STORAGE');
@ -637,7 +637,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock(); $path = $this->getMockBuilder(File::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -669,7 +669,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock(); $path = $this->getMockBuilder(File::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -714,7 +714,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock(); $path = $this->getMockBuilder(File::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -768,7 +768,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock(); $path = $this->getMockBuilder(File::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -820,7 +820,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -872,7 +872,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -904,7 +904,7 @@ class ShareAPIControllerTest extends TestCase {
])); ]));
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -923,7 +923,7 @@ class ShareAPIControllerTest extends TestCase {
*/ */
public function testCreateShareLinkNoPublicUpload() { public function testCreateShareLinkNoPublicUpload() {
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -943,7 +943,7 @@ class ShareAPIControllerTest extends TestCase {
*/ */
public function testCreateShareLinkPublicUploadFile() { public function testCreateShareLinkPublicUploadFile() {
$path = $this->getMockBuilder(File::class)->getMock(); $path = $this->getMockBuilder(File::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -962,7 +962,7 @@ class ShareAPIControllerTest extends TestCase {
$ocs = $this->mockFormatShare(); $ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -996,7 +996,7 @@ class ShareAPIControllerTest extends TestCase {
$ocs = $this->mockFormatShare(); $ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -1040,7 +1040,7 @@ class ShareAPIControllerTest extends TestCase {
])); ]));
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -1081,7 +1081,7 @@ class ShareAPIControllerTest extends TestCase {
$ocs = $this->mockFormatShare(); $ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(false); ->willReturn(false);
@ -1126,7 +1126,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder); ->willReturn($userFolder);
$path = $this->getMockBuilder(Folder::class)->getMock(); $path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage = $this->getMockBuilder(Storage::class)->getMock();
$storage->method('instanceOfStorage') $storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage') ->with('OCA\Files_Sharing\External\Storage')
->willReturn(true); ->willReturn(true);

View File

@ -58,7 +58,7 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getSubAdmin') ->method('getSubAdmin')
->willReturn($this->subAdminManager); ->willReturn($this->subAdminManager);
$this->userSession = $this->getMockBuilder('OCP\IUserSession') $this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$request = $this->getMockBuilder(IRequest::class) $request = $this->getMockBuilder(IRequest::class)

View File

@ -28,9 +28,13 @@ use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Encryption\Manager; use OC\Encryption\Manager;
use OC\Files\FileInfo; use OC\Files\FileInfo;
use OC\Files\View; use OC\Files\View;
use OCP\Files\Storage;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\UserInterface; use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase; use Test\TestCase;
/** /**
@ -70,11 +74,11 @@ class DecryptAllTest extends TestCase {
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager') $this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->view = $this->getMockBuilder('OC\Files\View') $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') $this->inputInterface = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') $this->outputInterface = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->userInterface = $this->getMockBuilder(UserInterface::class) $this->userInterface = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
@ -253,11 +257,11 @@ class DecryptAllTest extends TestCase {
->setMethods(['decryptFile']) ->setMethods(['decryptFile'])
->getMock(); ->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage') $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$sharedStorage = $this->getMockBuilder('OCP\Files\Storage') $sharedStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$sharedStorage->expects($this->once())->method('instanceOfStorage') $sharedStorage->expects($this->once())->method('instanceOfStorage')
@ -296,7 +300,7 @@ class DecryptAllTest extends TestCase {
->method('decryptFile') ->method('decryptFile')
->with('/user1/files/foo/subfile'); ->with('/user1/files/foo/subfile');
$progressBar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar') $progressBar = $this->getMockBuilder(ProgressBar::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']); $this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']);

View File

@ -26,6 +26,7 @@ namespace Test\Encryption;
use OC\Encryption\EncryptionWrapper; use OC\Encryption\EncryptionWrapper;
use OC\Encryption\Manager; use OC\Encryption\Manager;
use OC\Memcache\ArrayCache; use OC\Memcache\ArrayCache;
use OCP\Files\Storage;
use OCP\ILogger; use OCP\ILogger;
use Test\TestCase; use Test\TestCase;
@ -59,7 +60,7 @@ class EncryptionWrapperTest extends TestCase {
* @dataProvider provideWrapStorage * @dataProvider provideWrapStorage
*/ */
public function testWrapStorage($expectedWrapped, $wrappedStorages) { public function testWrapStorage($expectedWrapped, $wrappedStorages) {
$storage = $this->getMockBuilder('OC\Files\Storage\Storage') $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -24,6 +24,7 @@
namespace Test\Encryption\Keys; namespace Test\Encryption\Keys;
use OC\Encryption\Keys\Storage; use OC\Encryption\Keys\Storage;
use OC\Files\View;
use OCP\IConfig; use OCP\IConfig;
use Test\TestCase; use Test\TestCase;
@ -48,7 +49,7 @@ class StorageTest extends TestCase {
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->view = $this->getMockBuilder('OC\Files\View') $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -3,6 +3,7 @@
namespace Test\Encryption; namespace Test\Encryption;
use OC\Encryption\Util; use OC\Encryption\Util;
use OC\Files\View;
use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IEncryptionModule;
use OCP\IConfig; use OCP\IConfig;
use Test\TestCase; use Test\TestCase;
@ -33,7 +34,7 @@ class UtilTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->view = $this->getMockBuilder('OC\Files\View') $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -719,7 +719,7 @@ class EncryptionTest extends Storage {
} }
public function testCopyBetweenStorageMinimumEncryptedVersion() { public function testCopyBetweenStorageMinimumEncryptedVersion() {
$storage2 = $this->getMockBuilder('OCP\Files\Storage') $storage2 = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -768,7 +768,7 @@ class EncryptionTest extends Storage {
* @param bool $expectedEncrypted * @param bool $expectedEncrypted
*/ */
public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) { public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) {
$storage2 = $this->getMockBuilder('OCP\Files\Storage') $storage2 = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -830,11 +830,11 @@ class EncryptionTest extends Storage {
*/ */
public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) { public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) {
$sourceStorage = $this->getMockBuilder('OCP\Files\Storage') $sourceStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$targetStorage = $this->getMockBuilder('OCP\Files\Storage') $targetStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -9,6 +9,7 @@
namespace Test\Security; namespace Test\Security;
use OC\Files\Storage\Temporary; use OC\Files\Storage\Temporary;
use OC\Files\View;
use \OC\Security\CertificateManager; use \OC\Security\CertificateManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
@ -152,7 +153,7 @@ class CertificateManagerTest extends \Test\TestCase {
$expected $expected
) { ) {
$view = $this->getMockBuilder('OC\Files\View') $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$config = $this->createMock(IConfig::class); $config = $this->createMock(IConfig::class);

View File

@ -22,6 +22,7 @@
namespace Test\Session; namespace Test\Session;
use OC\Session\CryptoSessionData; use OC\Session\CryptoSessionData;
use OCP\ISession;
use Test\TestCase; use Test\TestCase;
class CryptoWrappingTest extends TestCase { class CryptoWrappingTest extends TestCase {
@ -37,7 +38,7 @@ class CryptoWrappingTest extends TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->wrappedSession = $this->getMockBuilder('OCP\ISession') $this->wrappedSession = $this->getMockBuilder(ISession::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->crypto = $this->getMockBuilder('OCP\Security\ICrypto') $this->crypto = $this->getMockBuilder('OCP\Security\ICrypto')