summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-09-06 14:18:57 +0200
committerGitHub <noreply@github.com>2016-09-06 14:18:57 +0200
commit6a6af86a1ca14e8b803d7cd8653733842e21d25f (patch)
tree37af6b38deb4ead471847261355dc9ef72287231
parent45a84f362333e8055227ea800bf67a8ea431f3d5 (diff)
parentc609e291bd5dce6976defc0537cdf48a3cc3528b (diff)
downloadnextcloud-server-6a6af86a1ca14e8b803d7cd8653733842e21d25f.tar.gz
nextcloud-server-6a6af86a1ca14e8b803d7cd8653733842e21d25f.zip
Merge pull request #1242 from nextcloud/bump_phpunit
Bump phpunit
-rw-r--r--.drone.yml14
-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
-rw-r--r--apps/files/tests/BackgroundJob/ScanFilesTest.php7
-rw-r--r--apps/files/tests/Controller/ApiControllerTest.php9
-rw-r--r--apps/files/tests/Service/TagServiceTest.php3
-rw-r--r--apps/files_external/tests/Auth/Password/GlobalAuth.php8
-rw-r--r--apps/files_external/tests/Command/ApplicableTest.php6
-rw-r--r--apps/files_external/tests/Command/ListCommandTest.php12
-rw-r--r--apps/files_external/tests/Controller/AjaxControllerTest.php15
-rw-r--r--apps/files_external/tests/Controller/GlobalStoragesControllerTest.php9
-rw-r--r--apps/files_external/tests/Controller/UserStoragesControllerTest.php12
-rw-r--r--apps/files_external/tests/Service/BackendServiceTest.php16
-rw-r--r--apps/files_external/tests/Service/StoragesServiceTest.php6
-rw-r--r--apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php6
-rw-r--r--apps/files_external/tests/Service/UserStoragesServiceTest.php3
-rw-r--r--apps/files_sharing/tests/MountProviderTest.php12
-rw-r--r--apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php6
-rw-r--r--apps/files_trashbin/tests/TrashbinTest.php2
-rw-r--r--apps/files_versions/tests/VersioningTest.php3
-rw-r--r--apps/user_ldap/tests/AccessTest.php24
-rw-r--r--apps/user_ldap/tests/ConnectionTest.php5
-rw-r--r--apps/user_ldap/tests/Group_LDAPTest.php3
-rw-r--r--apps/user_ldap/tests/Jobs/CleanUpTest.php10
-rw-r--r--apps/user_ldap/tests/Mapping/AbstractMappingTest.php4
-rw-r--r--apps/user_ldap/tests/User/ManagerTest.php27
-rw-r--r--apps/user_ldap/tests/User/UserTest.php44
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php92
-rw-r--r--apps/user_ldap/tests/WizardTest.php3
-rw-r--r--tests/Core/Middleware/TwoFactorMiddlewareTest.php22
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenMapperTest.php9
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenProviderTest.php19
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php10
-rw-r--r--tests/lib/AvatarTest.php30
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php229
-rw-r--r--tests/lib/Share20/ManagerTest.php196
46 files changed, 546 insertions, 408 deletions
diff --git a/.drone.yml b/.drone.yml
index 70c5f246a6a..c95164c9575 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -4,45 +4,45 @@ build:
commands:
- ./autotest-js.sh
nodb-php5.6:
- image: nextcloudci/php5.6:php5.6-1
+ image: nextcloudci/php5.6:php5.6-2
commands:
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
- NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
nodb-php7.0:
- image: nextcloudci/php7.0:php7.0-1
+ image: nextcloudci/php7.0:php7.0-2
commands:
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
- NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
sqlite-php5.6:
- image: nextcloudci/php5.6:1.0.6
+ image: nextcloudci/php5.6:php5.6-2
commands:
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
sqlite-php7.0:
- image: nextcloudci/php7.0:1.0.9
+ image: nextcloudci/php7.0:php7.0-2
commands:
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
mysql-php5.6:
- image: nextcloudci/php5.6:1.0.6
+ image: nextcloudci/php5.6:php5.6-2
commands:
- sleep 15 # gives the database enough time to initialize
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql
postgres-php5.6:
- image: nextcloudci/php5.6:1.0.6
+ image: nextcloudci/php5.6:php5.6-2
commands:
- sleep 10 # gives the database enough time to initialize
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql
integration:
- image: nextcloudci/php7.0:1.0.9
+ image: nextcloudci/php7.0:php7.0-2
commands:
- rm -rf data/* config/config.php # TODO: remove this - temporary fix for CI issues
- git submodule update --init
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')
diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php
index 16bf1d793b7..877c3bafd6d 100644
--- a/apps/files/tests/BackgroundJob/ScanFilesTest.php
+++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php
@@ -21,6 +21,7 @@
*/
namespace OCA\Files\Tests\BackgroundJob;
+use OCP\IUser;
use Test\TestCase;
use OCP\IConfig;
use OCP\IUserManager;
@@ -42,8 +43,8 @@ class ScanFilesTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('\OCP\IConfig');
- $this->userManager = $this->getMock('\OCP\IUserManager');
+ $this->config = $this->createMock(IConfig::class);
+ $this->userManager = $this->createMock(IUserManager::class);
$this->scanFiles = $this->getMockBuilder('\OCA\Files\BackgroundJob\ScanFiles')
->setConstructorArgs([
@@ -79,7 +80,7 @@ class ScanFilesTest extends TestCase {
}
public function testRunWithUsers() {
- $fakeUser = $this->getMock('\OCP\IUser');
+ $fakeUser = $this->createMock(IUser::class);
$this->config
->expects($this->at(0))
->method('getAppValue')
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php
index 348150e0e08..9bfc6d6f5e8 100644
--- a/apps/files/tests/Controller/ApiControllerTest.php
+++ b/apps/files/tests/Controller/ApiControllerTest.php
@@ -30,6 +30,9 @@ use OC\Files\FileInfo;
use OCP\AppFramework\Http;
use OCP\Files\NotFoundException;
use OCP\Files\StorageNotAvailableException;
+use OCP\IConfig;
+use OCP\IUser;
+use OCP\IUserSession;
use Test\TestCase;
use OCP\IRequest;
use OCA\Files\Service\TagService;
@@ -66,11 +69,11 @@ class ApiControllerTest extends TestCase {
$this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
- $this->user = $this->getMock('\OCP\IUser');
+ $this->user = $this->createMock(IUser::class);
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('user1'));
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->createMock(IUserSession::class);
$userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
@@ -83,7 +86,7 @@ class ApiControllerTest extends TestCase {
$this->preview = $this->getMockBuilder('\OCP\IPreview')
->disableOriginalConstructor()
->getMock();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->createMock(IConfig::class);
$this->userFolder = $this->getMockBuilder('\OC\Files\Node\Folder')
->disableOriginalConstructor()
->getMock();
diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php
index 388c9c28fa1..b8d36487585 100644
--- a/apps/files/tests/Service/TagServiceTest.php
+++ b/apps/files/tests/Service/TagServiceTest.php
@@ -25,6 +25,7 @@
namespace OCA\Files\Tests\Service;
use OCA\Files\Service\TagService;
+use OCP\IUserSession;
/**
* Class TagServiceTest
@@ -66,7 +67,7 @@ class TagServiceTest extends \Test\TestCase {
/**
* @var \OCP\IUserSession
*/
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->createMock(IUserSession::class);
$userSession->expects($this->any())
->method('getUser')
->withAnyParameters()
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php
index 1f0841a3493..405fbd2941c 100644
--- a/apps/files_external/tests/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php
@@ -24,6 +24,8 @@ namespace OCA\Files_External\Tests\Auth\Password;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
use OCA\Files_external\Lib\StorageConfig;
+use OCP\IL10N;
+use OCP\Security\ICredentialsManager;
use Test\TestCase;
class GlobalAuthTest extends TestCase {
@@ -44,14 +46,14 @@ class GlobalAuthTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->l10n = $this->getMock('\OCP\IL10N');
- $this->credentialsManager = $this->getMock('\OCP\Security\ICredentialsManager');
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->credentialsManager = $this->createMock(ICredentialsManager::class);
$this->instance = new GlobalAuth($this->l10n, $this->credentialsManager);
}
private function getStorageConfig($type, $config = []) {
/** @var \OCA\Files_External\Lib\StorageConfig|\PHPUnit_Framework_MockObject_MockObject $storageConfig */
- $storageConfig = $this->getMock('\OCA\Files_External\Lib\StorageConfig');
+ $storageConfig = $this->createMock(StorageConfig::class);
$storageConfig->expects($this->any())
->method('getType')
->will($this->returnValue($type));
diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php
index 7e2ba9563a2..70b18be6b7b 100644
--- a/apps/files_external/tests/Command/ApplicableTest.php
+++ b/apps/files_external/tests/Command/ApplicableTest.php
@@ -23,13 +23,15 @@
namespace OCA\Files_External\Tests\Command;
use OCA\Files_External\Command\Applicable;
+use OCP\IGroupManager;
+use OCP\IUserManager;
class ApplicableTest extends CommandTest {
private function getInstance($storageService) {
/** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject $userManager */
- $userManager = $this->getMock('\OCP\IUserManager');
+ $userManager = $this->createMock(IUserManager::class);
/** @var \OCP\IGroupManager|\PHPUnit_Framework_MockObject_MockObject $groupManager */
- $groupManager = $this->getMock('\OCP\IGroupManager');
+ $groupManager = $this->createMock(IGroupManager::class);
$userManager->expects($this->any())
->method('userExists')
diff --git a/apps/files_external/tests/Command/ListCommandTest.php b/apps/files_external/tests/Command/ListCommandTest.php
index 256b35d8883..7caf61cf57c 100644
--- a/apps/files_external/tests/Command/ListCommandTest.php
+++ b/apps/files_external/tests/Command/ListCommandTest.php
@@ -29,6 +29,10 @@ use OCA\Files_External\Lib\Auth\Password\Password;
use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
use OCA\Files_External\Lib\Backend\Local;
use OCA\Files_External\Lib\StorageConfig;
+use OCP\ISession;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Security\ICrypto;
use Symfony\Component\Console\Output\BufferedOutput;
class ListCommandTest extends CommandTest {
@@ -41,17 +45,17 @@ class ListCommandTest extends CommandTest {
/** @var \OCA\Files_External\Service\UserStoragesService|\PHPUnit_Framework_MockObject_MockObject $userService */
$userService = $this->getMock('\OCA\Files_External\Service\UserStoragesService', null, [], '', false);
/** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject $userManager */
- $userManager = $this->getMock('\OCP\IUserManager');
+ $userManager = $this->createMock(IUserManager::class);
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->createMock(IUserSession::class);
return new ListCommand($globalService, $userService, $userSession, $userManager);
}
public function testListAuthIdentifier() {
$l10n = $this->getMock('\OC_L10N', null, [], '', false);
- $session = $this->getMock('\OCP\ISession');
- $crypto = $this->getMock('\OCP\Security\ICrypto');
+ $session = $this->createMock(ISession::class);
+ $crypto = $this->createMock(ICrypto::class);
$instance = $this->getInstance();
$mount1 = new StorageConfig();
$mount1->setAuthMechanism(new Password($l10n));
diff --git a/apps/files_external/tests/Controller/AjaxControllerTest.php b/apps/files_external/tests/Controller/AjaxControllerTest.php
index 0fcd89611cf..8aba70e0d6b 100644
--- a/apps/files_external/tests/Controller/AjaxControllerTest.php
+++ b/apps/files_external/tests/Controller/AjaxControllerTest.php
@@ -28,6 +28,7 @@ use OCA\Files_External\Lib\Auth\PublicKey\RSA;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IGroupManager;
use OCP\IRequest;
+use OCP\IUser;
use OCP\IUserSession;
use Test\TestCase;
@@ -46,15 +47,15 @@ class AjaxControllerTest extends TestCase {
private $ajaxController;
public function setUp() {
- $this->request = $this->getMock('\\OCP\\IRequest');
+ $this->request = $this->createMock(IRequest::class);
$this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA')
->disableOriginalConstructor()
->getMock();
$this->globalAuth = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\Password\GlobalAuth')
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMock('\\OCP\\IUserSession');
- $this->groupManager = $this->getMock('\\OCP\\IGroupManager');
+ $this->userSession = $this->createMock(IUserSession::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
$this->ajaxController = new AjaxController(
'files_external',
@@ -90,7 +91,7 @@ class AjaxControllerTest extends TestCase {
}
public function testSaveGlobalCredentialsAsAdminForAnotherUser() {
- $user = $this->getMock('\\OCP\\IUser');
+ $user = $this->createMock(IUser::class);
$user
->expects($this->once())
->method('getUID')
@@ -113,7 +114,7 @@ class AjaxControllerTest extends TestCase {
}
public function testSaveGlobalCredentialsAsAdminForSelf() {
- $user = $this->getMock('\\OCP\\IUser');
+ $user = $this->createMock(IUser::class);
$user
->expects($this->once())
->method('getUID')
@@ -136,7 +137,7 @@ class AjaxControllerTest extends TestCase {
}
public function testSaveGlobalCredentialsAsNormalUserForSelf() {
- $user = $this->getMock('\\OCP\\IUser');
+ $user = $this->createMock(IUser::class);
$user
->expects($this->exactly(2))
->method('getUID')
@@ -159,7 +160,7 @@ class AjaxControllerTest extends TestCase {
}
public function testSaveGlobalCredentialsAsNormalUserForAnotherUser() {
- $user = $this->getMock('\\OCP\\IUser');
+ $user = $this->createMock(IUser::class);
$user
->expects($this->exactly(2))
->method('getUID')
diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
index 627892613ec..5c334efdf4c 100644
--- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
@@ -27,6 +27,9 @@ namespace OCA\Files_External\Tests\Controller;
use OCA\Files_External\Controller\GlobalStoragesController;
use \OCP\AppFramework\Http;
use \OCA\Files_External\Service\BackendService;
+use OCP\IL10N;
+use OCP\ILogger;
+use OCP\IRequest;
class GlobalStoragesControllerTest extends StoragesControllerTest {
public function setUp() {
@@ -40,10 +43,10 @@ class GlobalStoragesControllerTest extends StoragesControllerTest {
$this->controller = new GlobalStoragesController(
'files_external',
- $this->getMock('\OCP\IRequest'),
- $this->getMock('\OCP\IL10N'),
+ $this->createMock(IRequest::class),
+ $this->createMock(IL10N::class),
$this->service,
- $this->getMock('\OCP\ILogger')
+ $this->createMock(ILogger::class)
);
}
}
diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
index 36182505bf6..cdfcbcd1407 100644
--- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
@@ -28,6 +28,10 @@ use \OCA\Files_External\Controller\UserStoragesController;
use OCA\Files_External\Lib\StorageConfig;
use \OCP\AppFramework\Http;
use \OCA\Files_External\Service\BackendService;
+use OCP\IL10N;
+use OCP\ILogger;
+use OCP\IRequest;
+use OCP\IUserSession;
class UserStoragesControllerTest extends StoragesControllerTest {
@@ -47,11 +51,11 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->controller = new UserStoragesController(
'files_external',
- $this->getMock('\OCP\IRequest'),
- $this->getMock('\OCP\IL10N'),
+ $this->createMock(IRequest::class),
+ $this->createMock(IL10N::class),
$this->service,
- $this->getMock('\OCP\IUserSession'),
- $this->getMock('\OCP\ILogger')
+ $this->createMock(IUserSession::class),
+ $this->createMock(ILogger::class)
);
}
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index efc0a32af5a..cbb25579e11 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -21,7 +21,11 @@
*/
namespace OCA\Files_External\Tests\Service;
+use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
+use OCA\Files_External\Lib\Config\IBackendProvider;
use \OCA\Files_External\Service\BackendService;
+use OCP\IConfig;
+use OCP\IL10N;
class BackendServiceTest extends \Test\TestCase {
@@ -32,8 +36,8 @@ class BackendServiceTest extends \Test\TestCase {
protected $l10n;
protected function setUp() {
- $this->config = $this->getMock('\OCP\IConfig');
- $this->l10n = $this->getMock('\OCP\IL10N');
+ $this->config = $this->createMock(IConfig::class);
+ $this->l10n = $this->createMock(IL10N::class);
}
/**
@@ -97,7 +101,7 @@ class BackendServiceTest extends \Test\TestCase {
$backend1 = $this->getBackendMock('\Foo\Bar');
$backend2 = $this->getBackendMock('\Bar\Foo');
- $providerMock = $this->getMock('\OCA\Files_External\Lib\Config\IBackendProvider');
+ $providerMock = $this->createMock(IBackendProvider::class);
$providerMock->expects($this->once())
->method('getBackends')
->willReturn([$backend1, $backend2]);
@@ -115,7 +119,7 @@ class BackendServiceTest extends \Test\TestCase {
$backend1 = $this->getAuthMechanismMock('\Foo\Bar');
$backend2 = $this->getAuthMechanismMock('\Bar\Foo');
- $providerMock = $this->getMock('\OCA\Files_External\Lib\Config\IAuthMechanismProvider');
+ $providerMock = $this->createMock(IAuthMechanismProvider::class);
$providerMock->expects($this->once())
->method('getAuthMechanisms')
->willReturn([$backend1, $backend2]);
@@ -135,12 +139,12 @@ class BackendServiceTest extends \Test\TestCase {
$backend2 = $this->getBackendMock('\Dead\Beef');
- $provider1Mock = $this->getMock('\OCA\Files_External\Lib\Config\IBackendProvider');
+ $provider1Mock = $this->createMock(IBackendProvider::class);
$provider1Mock->expects($this->once())
->method('getBackends')
->willReturn([$backend1a, $backend1b]);
$service->registerBackendProvider($provider1Mock);
- $provider2Mock = $this->getMock('\OCA\Files_External\Lib\Config\IBackendProvider');
+ $provider2Mock = $this->createMock(IBackendProvider::class);
$provider2Mock->expects($this->once())
->method('getBackends')
->willReturn([$backend2]);
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php
index 5dcd93c8ae0..2776f24d5ab 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTest.php
@@ -31,6 +31,8 @@ use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\DBConfigService;
use OCA\Files_External\Service\StoragesService;
+use OCP\AppFramework\IAppContainer;
+use OCP\Files\Config\IUserMountCache;
class CleaningDBConfig extends DBConfigService {
private $mountIds = [];
@@ -94,7 +96,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
);
\OC_Mount_Config::$skipTest = true;
- $this->mountCache = $this->getMock('OCP\Files\Config\IUserMountCache');
+ $this->mountCache = $this->createMock(IUserMountCache::class);
// prepare BackendService mock
$this->backendService =
@@ -150,7 +152,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
Filesystem::signal_delete_mount,
get_class($this), 'deleteHookCallback');
- $containerMock = $this->getMock('\OCP\AppFramework\IAppContainer');
+ $containerMock = $this->createMock(IAppContainer::class);
$containerMock->method('query')
->will($this->returnCallback(function ($name) {
if ($name === 'OCA\Files_External\Service\BackendService') {
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index 6d4aa922c72..72e5dc15147 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -28,7 +28,9 @@ use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserGlobalStoragesService;
+use OCP\IGroupManager;
use OCP\IUser;
+use OCP\IUserSession;
use Test\Traits\UserTrait;
/**
@@ -63,13 +65,13 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->user = new \OC\User\User(self::USER_ID, null);
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->createMock(IUserSession::class);
$userSession
->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
- $this->groupManager = $this->getMock('\OCP\IGroupManager');
+ $this->groupManager = $this->createMock(IGroupManager::class);
$this->groupManager->method('isInGroup')
->will($this->returnCallback(function ($userId, $groupId) {
if ($userId === self::USER_ID) {
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index 85338065c73..3a820f644b4 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -30,6 +30,7 @@ use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCA\Files_External\Lib\StorageConfig;
+use OCP\IUserSession;
use Test\Traits\UserTrait;
/**
@@ -57,7 +58,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$this->user = \OC::$server->getUserManager()->get($this->userId);
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->createMock(IUserSession::class);
$userSession
->expects($this->any())
->method('getUser')
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index 576f05d565d..0be74a645a9 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -25,10 +25,12 @@
namespace OCA\Files_Sharing\Tests;
use OCA\Files_Sharing\MountProvider;
+use OCP\Files\IRootFolder;
use OCP\Files\Storage\IStorageFactory;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUser;
+use OCP\IUserManager;
use OCP\Share\IShare;
use OCP\Share\IManager;
use OCP\Files\Mount\IMountPoint;
@@ -69,7 +71,7 @@ class MountProviderTest extends \Test\TestCase {
}
private function makeMockShare($id, $nodeId, $owner = 'user2', $target = null, $permissions = 31) {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->expects($this->any())
->method('getPermissions')
->will($this->returnValue($permissions));
@@ -100,8 +102,8 @@ class MountProviderTest extends \Test\TestCase {
* - shares with a group in which the owner is already in
*/
public function testExcludeShares() {
- $rootFolder = $this->getMock('\OCP\Files\IRootFolder');
- $userManager = $this->getMock('\OCP\IUserManager');
+ $rootFolder = $this->createMock(IRootFolder::class);
+ $userManager = $this->createMock(IUserManager::class);
$userShares = [
$this->makeMockShare(1, 100, 'user2', '/share2', 0),
$this->makeMockShare(2, 100, 'user2', '/share2', 31),
@@ -277,8 +279,8 @@ class MountProviderTest extends \Test\TestCase {
* @param array $expectedShares array of expected supershare specs
*/
public function testMergeShares($userShares, $groupShares, $expectedShares) {
- $rootFolder = $this->getMock('\OCP\Files\IRootFolder');
- $userManager = $this->getMock('\OCP\IUserManager');
+ $rootFolder = $this->createMock(IRootFolder::class);
+ $userManager = $this->createMock(IUserManager::class);
$userShares = array_map(function($shareSpec) {
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
diff --git a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php
index d92984bbce9..4bf533194b4 100644
--- a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php
+++ b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php
@@ -24,15 +24,17 @@
namespace OCA\Files_Trashbin\Tests\BackgroundJob;
use \OCA\Files_Trashbin\BackgroundJob\ExpireTrash;
+use OCP\BackgroundJob\IJobList;
+use OCP\IUserManager;
class ExpireTrashTest extends \Test\TestCase {
public function testConstructAndRun() {
$backgroundJob = new ExpireTrash(
- $this->getMock('OCP\IUserManager'),
+ $this->createMock(IUserManager::class),
$this->getMockBuilder('OCA\Files_Trashbin\Expiration')->disableOriginalConstructor()->getMock()
);
- $jobList = $this->getMock('\OCP\BackgroundJob\IJobList');
+ $jobList = $this->createMock(IJobList::class);
/** @var \OC\BackgroundJob\JobList $jobList */
$backgroundJob->execute($jobList);
diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php
index cb5a9fed5bb..7e4cdb112e8 100644
--- a/apps/files_trashbin/tests/TrashbinTest.php
+++ b/apps/files_trashbin/tests/TrashbinTest.php
@@ -112,7 +112,7 @@ class TrashbinTest extends \Test\TestCase {
\OC::$server->getAppManager()->enableApp('files_trashbin');
$config = \OC::$server->getConfig();
- $mockConfig = $this->getMock('\OCP\IConfig');
+ $mockConfig = $this->createMock(\OCP\IConfig::class);
$mockConfig->expects($this->any())
->method('getSystemValue')
->will($this->returnCallback(function ($key, $default) use ($config) {
diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php
index 15bcaf9a90c..6e6551089cc 100644
--- a/apps/files_versions/tests/VersioningTest.php
+++ b/apps/files_versions/tests/VersioningTest.php
@@ -36,6 +36,7 @@ namespace OCA\Files_Versions\Tests;
require_once __DIR__ . '/../appinfo/app.php';
use OC\Files\Storage\Temporary;
+use OCP\IConfig;
/**
* Class Test_Files_versions
@@ -79,7 +80,7 @@ class VersioningTest extends \Test\TestCase {
parent::setUp();
$config = \OC::$server->getConfig();
- $mockConfig = $this->getMock('\OCP\IConfig');
+ $mockConfig = $this->createMock(IConfig::class);
$mockConfig->expects($this->any())
->method('getSystemValue')
->will($this->returnCallback(function ($key, $default) use ($config) {
diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php
index 5e99583c70f..08e7c9f79f5 100644
--- a/apps/user_ldap/tests/AccessTest.php
+++ b/apps/user_ldap/tests/AccessTest.php
@@ -28,6 +28,14 @@ namespace OCA\User_LDAP\Tests;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUserManager;
/**
* Class AccessTest
@@ -47,19 +55,19 @@ class AccessTest extends \Test\TestCase {
$accMethods = get_class_methods('\OCA\User_LDAP\Access');
$umMethods = get_class_methods('\OCA\User_LDAP\User\Manager');
}
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+ $lw = $this->createMock(ILDAPWrapper::class);
$connector = $this->getMock('\OCA\User_LDAP\Connection',
$conMethods,
array($lw, null, null));
$um = $this->getMock('\OCA\User_LDAP\User\Manager',
$umMethods, array(
- $this->getMock('\OCP\IConfig'),
- $this->getMock('\OCA\User_LDAP\FilesystemHelper'),
- $this->getMock('\OCA\User_LDAP\LogWrapper'),
- $this->getMock('\OCP\IAvatarManager'),
- $this->getMock('\OCP\Image'),
- $this->getMock('\OCP\IDBConnection'),
- $this->getMock('\OCP\IUserManager')));
+ $this->createMock(IConfig::class),
+ $this->createMock(FilesystemHelper::class),
+ $this->createMock(LogWrapper::class),
+ $this->createMock(IAvatarManager::class),
+ $this->createMock(Image::class),
+ $this->createMock(IDBConnection::class),
+ $this->createMock(IUserManager::class)));
$helper = new \OCA\User_LDAP\Helper();
return array($lw, $connector, $um, $helper);
diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php
index ed0a1481589..fcff65efb33 100644
--- a/apps/user_ldap/tests/ConnectionTest.php
+++ b/apps/user_ldap/tests/ConnectionTest.php
@@ -25,6 +25,7 @@
namespace OCA\User_LDAP\Tests;
use OCA\User_LDAP\Connection;
+use OCA\User_LDAP\ILDAPWrapper;
/**
* Class Test_Connection
@@ -43,7 +44,7 @@ class ConnectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->ldap = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+ $this->ldap = $this->createMock(ILDAPWrapper::class);
// we use a mock here to replace the cache mechanism, due to missing DI in LDAP backend.
$this->connection = $this->getMockBuilder('OCA\User_LDAP\Connection')
->setMethods(['getFromCache', 'writeToCache'])
@@ -59,7 +60,7 @@ class ConnectionTest extends \Test\TestCase {
//background: upon login a bind is done with the user credentials
//which is valid for the whole LDAP resource. It needs to be reset
//to the agent's credentials
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+ $lw = $this->createMock(ILDAPWrapper::class);
$connection = new Connection($lw, '', null);
$agent = array(
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php
index 83ec2dedf22..12f7eaa2256 100644
--- a/apps/user_ldap/tests/Group_LDAPTest.php
+++ b/apps/user_ldap/tests/Group_LDAPTest.php
@@ -31,6 +31,7 @@ namespace OCA\User_LDAP\Tests;
use OCA\User_LDAP\Group_LDAP as GroupLDAP;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
+use OCA\User_LDAP\ILDAPWrapper;
/**
* Class GroupLDAPTest
@@ -48,7 +49,7 @@ class Group_LDAPTest extends \Test\TestCase {
$conMethods = get_class_methods('\OCA\User_LDAP\Connection');
$accMethods = get_class_methods('\OCA\User_LDAP\Access');
}
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+ $lw = $this->createMock(ILDAPWrapper::class);
$connector = $this->getMock('\OCA\User_LDAP\Connection',
$conMethods,
array($lw, null, null));
diff --git a/apps/user_ldap/tests/Jobs/CleanUpTest.php b/apps/user_ldap/tests/Jobs/CleanUpTest.php
index 45e7998da01..62cebcf328e 100644
--- a/apps/user_ldap/tests/Jobs/CleanUpTest.php
+++ b/apps/user_ldap/tests/Jobs/CleanUpTest.php
@@ -24,6 +24,10 @@
namespace OCA\User_LDAP\Tests\Jobs;
+use OCA\User_LDAP\Helper;
+use OCP\IConfig;
+use OCP\IDBConnection;
+
class CleanUpTest extends \Test\TestCase {
public function getMocks() {
$mocks = array();
@@ -35,9 +39,9 @@ class CleanUpTest extends \Test\TestCase {
$this->getMockBuilder('\OCA\User_LDAP\User\DeletedUsersIndex')
->disableOriginalConstructor()
->getMock();
- $mocks['ocConfig'] = $this->getMock('\OCP\IConfig');
- $mocks['db'] = $this->getMock('\OCP\IDBConnection');
- $mocks['helper'] = $this->getMock('\OCA\User_LDAP\Helper');
+ $mocks['ocConfig'] = $this->createMock(IConfig::class);
+ $mocks['db'] = $this->createMock(IDBConnection::class);
+ $mocks['helper'] = $this->createMock(Helper::class);
return $mocks;
}
diff --git a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
index 1d988126df0..91013085c2c 100644
--- a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
+++ b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
@@ -26,6 +26,8 @@
namespace OCA\User_LDAP\Tests\Mapping;
+use OCP\IDBConnection;
+
abstract class AbstractMappingTest extends \Test\TestCase {
abstract public function getMapper(\OCP\IDBConnection $dbMock);
@@ -33,7 +35,7 @@ abstract class AbstractMappingTest extends \Test\TestCase {
* kiss test on isColNameValid
*/
public function testIsColNameValid() {
- $dbMock = $this->getMock('\OCP\IDBConnection');
+ $dbMock = $this->createMock(IDBConnection::class);
$mapper = $this->getMapper($dbMock);
$this->assertTrue($mapper->isColNameValid('ldap_dn'));
diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php
index b3f22d6a068..16d6a3d9d6e 100644
--- a/apps/user_ldap/tests/User/ManagerTest.php
+++ b/apps/user_ldap/tests/User/ManagerTest.php
@@ -26,7 +26,16 @@
namespace OCA\User_LDAP\Tests\User;
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
+use OCA\User_LDAP\User\IUserTools;
use OCA\User_LDAP\User\Manager;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUserManager;
/**
* Class Test_User_Manager
@@ -38,17 +47,17 @@ use OCA\User_LDAP\User\Manager;
class ManagerTest extends \Test\TestCase {
private function getTestInstances() {
- $access = $this->getMock('\OCA\User_LDAP\User\IUserTools');
- $config = $this->getMock('\OCP\IConfig');
- $filesys = $this->getMock('\OCA\User_LDAP\FilesystemHelper');
- $log = $this->getMock('\OCA\User_LDAP\LogWrapper');
- $avaMgr = $this->getMock('\OCP\IAvatarManager');
- $image = $this->getMock('\OCP\Image');
- $dbc = $this->getMock('\OCP\IDBConnection');
- $userMgr = $this->getMock('\OCP\IUserManager');
+ $access = $this->createMock(IUserTools::class);
+ $config = $this->createMock(IConfig::class);
+ $filesys = $this->createMock(FilesystemHelper::class);
+ $log = $this->createMock(LogWrapper::class);
+ $avaMgr = $this->createMock(IAvatarManager::class);
+ $image = $this->createMock(Image::class);
+ $dbc = $this->createMock(IDBConnection::class);
+ $userMgr = $this->createMock(IUserManager::class);
$connection = new \OCA\User_LDAP\Connection(
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper'),
+ $lw = $this->createMock(ILDAPWrapper::class),
'',
null
);
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php
index d9e43dee047..6e6e2ad66b1 100644
--- a/apps/user_ldap/tests/User/UserTest.php
+++ b/apps/user_ldap/tests/User/UserTest.php
@@ -25,7 +25,17 @@
namespace OCA\User_LDAP\Tests\User;
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
+use OCA\User_LDAP\User\IUserTools;
use OCA\User_LDAP\User\User;
+use OCP\IAvatar;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUser;
use OCP\IUserManager;
/**
@@ -38,14 +48,14 @@ use OCP\IUserManager;
class UserTest extends \Test\TestCase {
private function getTestInstances() {
- $access = $this->getMock('\OCA\User_LDAP\User\IUserTools');
- $config = $this->getMock('\OCP\IConfig');
- $filesys = $this->getMock('\OCA\User_LDAP\FilesystemHelper');
- $log = $this->getMock('\OCA\User_LDAP\LogWrapper');
- $avaMgr = $this->getMock('\OCP\IAvatarManager');
- $image = $this->getMock('\OCP\Image');
- $dbc = $this->getMock('\OCP\IDBConnection');
- $userMgr = $this->getMock('\OCP\IUserManager');
+ $access = $this->createMock(IUserTools::class);
+ $config = $this->createMock(IConfig::class);
+ $filesys = $this->createMock(FilesystemHelper::class);
+ $log = $this->createMock(LogWrapper::class);
+ $avaMgr = $this->createMock(IAvatarManager::class);
+ $image = $this->createMock(Image::class);
+ $dbc = $this->createMock(IDBConnection::class);
+ $userMgr = $this->createMock(IUserManager::class);
return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr);
}
@@ -62,10 +72,10 @@ class UserTest extends \Test\TestCase {
unset($accMethods[array_search('getConnection', $accMethods)]);
$umMethods = get_class_methods('\OCA\User_LDAP\User\Manager');
}
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
- $im = $this->getMock('\OCP\Image');
+ $lw = $this->createMock(ILDAPWrapper::class);
+ $im = $this->createMock(Image::class);
if (is_null($userMgr)) {
- $userMgr = $this->getMock('\OCP\IUserManager');
+ $userMgr = $this->createMock(IUserManager::class);
}
$um = $this->getMock('\OCA\User_LDAP\User\Manager',
$umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr));
@@ -212,7 +222,7 @@ class UserTest extends \Test\TestCase {
$this->equalTo('myquota'))
->will($this->returnValue(array('42 GB')));
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('setQuota')
->with('42 GB');
@@ -257,7 +267,7 @@ class UserTest extends \Test\TestCase {
$this->equalTo('myquota'))
->will($this->returnValue(false));
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('setQuota')
->with('25 GB');
@@ -302,7 +312,7 @@ class UserTest extends \Test\TestCase {
$this->equalTo('myquota'))
->will($this->returnValue(array('27 GB')));
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('setQuota')
->with('27 GB');
@@ -416,7 +426,7 @@ class UserTest extends \Test\TestCase {
$access->expects($this->never())
->method('readAttribute');
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('setQuota')
->with($readQuota);
@@ -466,7 +476,7 @@ class UserTest extends \Test\TestCase {
->method('isLoaded')
->will($this->returnValue(true));
- $avatar = $this->getMock('\OCP\IAvatar');
+ $avatar = $this->createMock(IAvatar::class);
$avatar->expects($this->once())
->method('set')
->with($this->isInstanceOf($image));
@@ -524,7 +534,7 @@ class UserTest extends \Test\TestCase {
->method('isLoaded')
->will($this->returnValue(true));
- $avatar = $this->getMock('\OCP\IAvatar');
+ $avatar = $this->createMock(IAvatar::class);
$avatar->expects($this->once())
->method('set')
->with($this->isInstanceOf($image));
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index 47e789142e5..0e08998d13b 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -28,9 +28,17 @@
namespace OCA\User_LDAP\Tests;
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\ILDAPWrapper;
+use OCA\User_LDAP\LogWrapper;
use OCA\User_LDAP\User_LDAP as UserLDAP;
use \OCA\User_LDAP\Access;
use \OCA\User_LDAP\Connection;
+use OCP\IAvatarManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Image;
+use OCP\IUserManager;
/**
* Class Test_User_Ldap_Direct
@@ -65,12 +73,12 @@ class User_LDAPTest extends \Test\TestCase {
unset($uMethods[array_search('getDN', $uMethods)]);
unset($uMethods[array_search('__construct', $uMethods)]);
}
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+ $lw = $this->createMock(ILDAPWrapper::class);
$connector = $this->getMock('\OCA\User_LDAP\Connection',
$conMethods,
array($lw, null, null));
- $this->configMock = $this->getMock('\OCP\IConfig');
+ $this->configMock = $this->createMock(IConfig::class);
$offlineUser = $this->getMockBuilder('\OCA\User_LDAP\User\OfflineUser')
->disableOriginalConstructor()
@@ -80,12 +88,12 @@ class User_LDAPTest extends \Test\TestCase {
->setMethods(['getDeletedUser'])
->setConstructorArgs([
$this->configMock,
- $this->getMock('\OCA\User_LDAP\FilesystemHelper'),
- $this->getMock('\OCA\User_LDAP\LogWrapper'),
- $this->getMock('\OCP\IAvatarManager'),
- $this->getMock('\OCP\Image'),
- $this->getMock('\OCP\IDBConnection'),
- $this->getMock('\OCP\IUserManager')
+ $this->createMock(FilesystemHelper::class),
+ $this->createMock(LogWrapper::class),
+ $this->createMock(IAvatarManager::class),
+ $this->createMock(Image::class),
+ $this->createMock(IDBConnection::class),
+ $this->createMock(IUserManager::class)
])
->getMock();
@@ -189,7 +197,7 @@ class User_LDAPTest extends \Test\TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'dt19');
@@ -200,7 +208,7 @@ class User_LDAPTest extends \Test\TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'wrong');
@@ -211,7 +219,7 @@ class User_LDAPTest extends \Test\TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('mallory', 'evil');
@@ -226,7 +234,7 @@ class User_LDAPTest extends \Test\TestCase {
->method('username2dn')
->will($this->returnValue(false));
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'dt19');
@@ -236,7 +244,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testCheckPasswordPublicAPI() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'dt19');
@@ -246,7 +254,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testCheckPasswordPublicAPIWrongPassword() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'wrong');
@@ -256,7 +264,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testCheckPasswordPublicAPIWrongUser() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('mallory', 'evil');
@@ -265,7 +273,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testDeleteUserCancel() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->deleteUser('notme');
$this->assertFalse($result);
}
@@ -282,7 +290,7 @@ class User_LDAPTest extends \Test\TestCase {
->method('getUserMapper')
->will($this->returnValue($mapping));
- $config = $this->getMock('\OCP\IConfig');
+ $config = $this->createMock(IConfig::class);
$config->expects($this->exactly(2))
->method('getUserValue')
->will($this->onConsecutiveCalls('1', '/var/vhome/jdings/'));
@@ -348,7 +356,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersNoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->getUsers();
$this->assertEquals(3, count($result));
@@ -357,7 +365,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersLimitOffset() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->getUsers('', 1, 2);
$this->assertEquals(1, count($result));
@@ -366,7 +374,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersLimitOffset2() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->getUsers('', 2, 1);
$this->assertEquals(2, count($result));
@@ -375,7 +383,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersSearchWithResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->getUsers('yo');
$this->assertEquals(2, count($result));
@@ -384,7 +392,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersSearchEmptyResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->getUsers('nix');
$this->assertEquals(0, count($result));
@@ -393,7 +401,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersViaAPINoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers();
@@ -403,7 +411,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersViaAPILimitOffset() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 1, 2);
@@ -413,7 +421,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersViaAPILimitOffset2() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 2, 1);
@@ -423,7 +431,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersViaAPISearchWithResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('yo');
@@ -433,7 +441,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetUsersViaAPISearchEmptyResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('nix');
@@ -442,7 +450,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testUserExists() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->expects($this->any())
@@ -464,7 +472,7 @@ class User_LDAPTest extends \Test\TestCase {
*/
public function testUserExistsForDeleted() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->expects($this->any())
@@ -482,7 +490,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testUserExistsForNeverExisting() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->expects($this->any())
@@ -501,7 +509,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testUserExistsPublicAPI() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
\OC_User::useBackend($backend);
@@ -524,7 +532,7 @@ class User_LDAPTest extends \Test\TestCase {
*/
public function testUserExistsPublicAPIForDeleted() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
\OC_User::useBackend($backend);
@@ -543,7 +551,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testUserExistsPublicAPIForNeverExisting() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
\OC_User::useBackend($backend);
@@ -563,7 +571,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testDeleteUser() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
//we do not support deleting users at all
$result = $backend->deleteUser('gunslinger');
@@ -572,7 +580,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetHomeAbsolutePath() {
$access = $this->getAccessMock();
- $config = $this->getMock('\OCP\IConfig');
+ $config = $this->createMock(IConfig::class);
$backend = new UserLDAP($access, $config);
$this->prepareMockForUserExists($access);
@@ -607,7 +615,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetHomeRelative() {
$access = $this->getAccessMock();
- $config = $this->getMock('\OCP\IConfig');
+ $config = $this->createMock(IConfig::class);
$backend = new UserLDAP($access, $config);
$this->prepareMockForUserExists($access);
@@ -651,7 +659,7 @@ class User_LDAPTest extends \Test\TestCase {
*/
public function testGetHomeNoPath() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -682,7 +690,7 @@ class User_LDAPTest extends \Test\TestCase {
*/
public function testGetHomeDeletedUser() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -753,7 +761,7 @@ class User_LDAPTest extends \Test\TestCase {
public function testGetDisplayName() {
$access = $this->getAccessMock();
$this->prepareAccessForGetDisplayName($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -794,7 +802,7 @@ class User_LDAPTest extends \Test\TestCase {
}
}));
$this->prepareAccessForGetDisplayName($access);
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -824,7 +832,7 @@ class User_LDAPTest extends \Test\TestCase {
->method('countUsers')
->will($this->returnValue(5));
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->countUsers();
$this->assertEquals(5, $result);
@@ -837,7 +845,7 @@ class User_LDAPTest extends \Test\TestCase {
->method('countUsers')
->will($this->returnValue(false));
- $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class));
$result = $backend->countUsers();
$this->assertFalse($result);
diff --git a/apps/user_ldap/tests/WizardTest.php b/apps/user_ldap/tests/WizardTest.php
index e82cbcfc82a..3aefa8779a2 100644
--- a/apps/user_ldap/tests/WizardTest.php
+++ b/apps/user_ldap/tests/WizardTest.php
@@ -26,6 +26,7 @@
namespace OCA\User_LDAP\Tests;
+use OCA\User_LDAP\ILDAPWrapper;
use \OCA\User_LDAP\Wizard;
/**
@@ -59,7 +60,7 @@ class WizardTest extends \Test\TestCase {
$connMethods = get_class_methods('\OCA\User_LDAP\Connection');
$accMethods = get_class_methods('\OCA\User_LDAP\Access');
}
- $lw = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+ $lw = $this->createMock(ILDAPWrapper::class);
$conf = $this->getMock('\OCA\User_LDAP\Configuration',
$confMethods,
array($lw, null, null));
diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
index 8247efa1b82..fc8cf0d8b7e 100644
--- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php
+++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
@@ -24,6 +24,12 @@ namespace Test\Core\Middleware;
use OC\Core\Middleware\TwoFactorMiddleware;
use OC\AppFramework\Http\Request;
+use OCP\AppFramework\Utility\IControllerMethodReflector;
+use OCP\IConfig;
+use OCP\ISession;
+use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\Security\ISecureRandom;
use Test\TestCase;
class TwoFactorMiddlewareTest extends TestCase {
@@ -47,17 +53,17 @@ class TwoFactorMiddlewareTest extends TestCase {
$this->userSession = $this->getMockBuilder('\OC\User\Session')
->disableOriginalConstructor()
->getMock();
- $this->session = $this->getMock('\OCP\ISession');
- $this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
- $this->reflector = $this->getMock('\OCP\AppFramework\Utility\IControllerMethodReflector');
+ $this->session = $this->createMock(ISession::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->reflector = $this->createMock(IControllerMethodReflector::class);
$this->request = new Request(
[
'server' => [
'REQUEST_URI' => 'test/url'
]
],
- $this->getMock('\OCP\Security\ISecureRandom'),
- $this->getMock('\OCP\IConfig')
+ $this->createMock(ISecureRandom::class),
+ $this->createMock(IConfig::class)
);
$this->middleware = new TwoFactorMiddleware($this->twoFactorManager, $this->userSession, $this->session, $this->urlGenerator, $this->reflector, $this->request);
@@ -90,7 +96,7 @@ class TwoFactorMiddlewareTest extends TestCase {
}
public function testBeforeControllerNoTwoFactorCheckNeeded() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->reflector->expects($this->once())
->method('hasAnnotation')
@@ -114,7 +120,7 @@ class TwoFactorMiddlewareTest extends TestCase {
* @expectedException \OC\Authentication\Exceptions\TwoFactorAuthRequiredException
*/
public function testBeforeControllerTwoFactorAuthRequired() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->reflector->expects($this->once())
->method('hasAnnotation')
@@ -142,7 +148,7 @@ class TwoFactorMiddlewareTest extends TestCase {
* @expectedException \OC\Authentication\Exceptions\UserAlreadyLoggedInException
*/
public function testBeforeControllerUserAlreadyLoggedIn() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->reflector->expects($this->once())
->method('hasAnnotation')
diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
index 6b73cab5ed0..d71d9468477 100644
--- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
@@ -27,6 +27,7 @@ use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\DefaultTokenMapper;
use OC\Authentication\Token\IToken;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IUser;
use Test\TestCase;
/**
@@ -150,7 +151,7 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testGetTokenByUser() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1'));
@@ -159,7 +160,7 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testGetTokenByUserNotFound() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1000'));
@@ -168,7 +169,7 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testDeleteById() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('id')
->from('authtoken')
@@ -184,7 +185,7 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testDeleteByIdWrongUser() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$id = 33;
$user->expects($this->once())
->method('getUID')
diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
index 28a59529dec..7f90cf051f4 100644
--- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
@@ -26,6 +26,11 @@ use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\DefaultTokenProvider;
use OC\Authentication\Token\IToken;
use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IConfig;
+use OCP\ILogger;
+use OCP\IUser;
+use OCP\Security\ICrypto;
use Test\TestCase;
class DefaultTokenProviderTest extends TestCase {
@@ -45,10 +50,10 @@ class DefaultTokenProviderTest extends TestCase {
$this->mapper = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenMapper')
->disableOriginalConstructor()
->getMock();
- $this->crypto = $this->getMock('\OCP\Security\ICrypto');
- $this->config = $this->getMock('\OCP\IConfig');
- $this->logger = $this->getMock('\OCP\ILogger');
- $this->timeFactory = $this->getMock('\OCP\AppFramework\Utility\ITimeFactory');
+ $this->crypto = $this->createMock(ICrypto::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->logger = $this->createMock(ILogger::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
$this->time = 1313131;
$this->timeFactory->expects($this->any())
->method('getTime')
@@ -118,7 +123,7 @@ class DefaultTokenProviderTest extends TestCase {
}
public function testGetTokenByUser() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->mapper->expects($this->once())
->method('getTokenByUser')
->with($user)
@@ -212,7 +217,7 @@ class DefaultTokenProviderTest extends TestCase {
* @expectedException \OC\Authentication\Exceptions\InvalidTokenException
*/
public function testSetPasswordInvalidToken() {
- $token = $this->getMock('\OC\Authentication\Token\IToken');
+ $token = $this->createMock(IToken::class);
$tokenId = 'token123';
$password = '123456';
@@ -229,7 +234,7 @@ class DefaultTokenProviderTest extends TestCase {
public function testInvaildateTokenById() {
$id = 123;
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->mapper->expects($this->once())
->method('deleteById')
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index 83a74f2f253..b3fd28a30ad 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -59,19 +59,19 @@ class ManagerTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->user = $this->getMockBuilder('\OCP\IUser')->getMock();
+ $this->user = $this->createMock(IUser::class);
$this->appManager = $this->getMockBuilder('\OC\App\AppManager')
->disableOriginalConstructor()
->getMock();
- $this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->session = $this->createMock(ISession::class);
+ $this->config = $this->createMock(IConfig::class);
$this->manager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
->setConstructorArgs([$this->appManager, $this->session, $this->config])
->setMethods(['loadTwoFactorApp']) // Do not actually load the apps
->getMock();
- $this->fakeProvider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')->getMock();
+ $this->fakeProvider = $this->createMock(IProvider::class);
$this->fakeProvider->expects($this->any())
->method('getId')
->will($this->returnValue('email'));
@@ -268,7 +268,7 @@ class ManagerTest extends TestCase {
}
public function testNeedsSecondFactor() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->session->expects($this->once())
->method('exists')
->with('two_factor_auth_uid')
diff --git a/tests/lib/AvatarTest.php b/tests/lib/AvatarTest.php
index f515f0d013f..7f012c895fd 100644
--- a/tests/lib/AvatarTest.php
+++ b/tests/lib/AvatarTest.php
@@ -8,7 +8,11 @@
namespace Test;
+use OCP\Files\File;
use OCP\Files\Folder;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\ILogger;
class AvatarTest extends \Test\TestCase {
/** @var Folder | \PHPUnit_Framework_MockObject_MockObject */
@@ -26,18 +30,18 @@ class AvatarTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
+ $this->folder = $this->createMock(Folder::class);
/** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */
- $l = $this->getMockBuilder('OCP\IL10N')->getMock();
+ $l = $this->createMock(IL10N::class);
$l->method('t')->will($this->returnArgument(0));
$this->user = $this->getMockBuilder('OC\User\User')->disableOriginalConstructor()->getMock();
- $this->config = $this->getMockBuilder('OCP\IConfig')->getMock();
+ $this->config = $this->createMock(IConfig::class);
$this->avatar = new \OC\Avatar(
$this->folder,
$l,
$this->user,
- $this->getMockBuilder('\OCP\ILogger')->getMock(),
+ $this->createMock(ILogger::class),
$this->config
);
}
@@ -55,7 +59,7 @@ class AvatarTest extends \Test\TestCase {
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->createMock(File::class);
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('get')->with('avatar.128.jpg')->willReturn($file);
@@ -70,7 +74,7 @@ class AvatarTest extends \Test\TestCase {
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->createMock(File::class);
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('get')->with('avatar.jpg')->willReturn($file);
@@ -88,7 +92,7 @@ class AvatarTest extends \Test\TestCase {
$expected2 = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2->resize(32);
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->createMock(File::class);
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('get')
@@ -102,7 +106,7 @@ class AvatarTest extends \Test\TestCase {
}
));
- $newFile = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $newFile = $this->createMock(File::class);
$newFile->expects($this->once())
->method('putContent')
->with($expected2->data());
@@ -140,22 +144,22 @@ class AvatarTest extends \Test\TestCase {
}
public function testSetAvatar() {
- $avatarFileJPG = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $avatarFileJPG = $this->createMock(File::class);
$avatarFileJPG->method('getName')
->willReturn('avatar.jpg');
$avatarFileJPG->expects($this->once())->method('delete');
- $avatarFilePNG = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $avatarFilePNG = $this->createMock(File::class);
$avatarFilePNG->method('getName')
->willReturn('avatar.png');
$avatarFilePNG->expects($this->once())->method('delete');
- $resizedAvatarFile = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $resizedAvatarFile = $this->createMock(File::class);
$resizedAvatarFile->method('getName')
->willReturn('avatar.32.jpg');
$resizedAvatarFile->expects($this->once())->method('delete');
- $nonAvatarFile = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $nonAvatarFile = $this->createMock(File::class);
$nonAvatarFile->method('getName')
->willReturn('avatarX');
$nonAvatarFile->expects($this->never())->method('delete');
@@ -163,7 +167,7 @@ class AvatarTest extends \Test\TestCase {
$this->folder->method('getDirectoryListing')
->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]);
- $newFile = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $newFile = $this->createMock(File::class);
$this->folder->expects($this->once())
->method('newFile')
->with('avatar.png')
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 6ef00721a70..ae9ad47b9ae 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -22,11 +22,16 @@ namespace Test\Share20;
use OC\Share20\Exception\ProviderException;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\Files\File;
+use OCP\Files\Folder;
use OCP\IDBConnection;
+use OCP\IGroup;
+use OCP\IUser;
use OCP\IUserManager;
use OCP\IGroupManager;
use OCP\Files\IRootFolder;
use OC\Share20\DefaultShareProvider;
+use OCP\Share\IShare;
/**
* Class DefaultShareProviderTest
@@ -53,9 +58,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function setUp() {
$this->dbConn = \OC::$server->getDatabaseConnection();
- $this->userManager = $this->getMock('OCP\IUserManager');
- $this->groupManager = $this->getMock('OCP\IGroupManager');
- $this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->rootFolder = $this->createMock(IRootFolder::class);
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
@@ -136,13 +141,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $qb->getLastInsertId();
- $sharedBy = $this->getMock('OCP\IUser');
+ $sharedBy = $this->createMock(IUser::class);
$sharedBy->method('getUID')->willReturn('sharedBy');
- $shareOwner = $this->getMock('OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $ownerPath = $this->getMock('\OCP\Files\File');
- $shareOwnerFolder = $this->getMock('\OCP\Files\Folder');
+ $ownerPath = $this->createMock(File::class);
+ $shareOwnerFolder = $this->createMock(Folder::class);
$shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
$this->rootFolder
@@ -218,9 +223,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $qb->getLastInsertId();
- $ownerPath = $this->getMock('\OCP\Files\File');
+ $ownerPath = $this->createMock(File::class);
- $shareOwnerFolder = $this->getMock('\OCP\Files\Folder');
+ $shareOwnerFolder = $this->createMock(Folder::class);
$shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
$this->rootFolder
@@ -263,8 +268,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
// Get the id
$id = $qb->getLastInsertId();
- $ownerPath = $this->getMock('\OCP\Files\Folder');
- $shareOwnerFolder = $this->getMock('\OCP\Files\Folder');
+ $ownerPath = $this->createMock(Folder::class);
+ $shareOwnerFolder = $this->createMock(Folder::class);
$shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
$this->rootFolder
@@ -291,15 +296,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null);
$this->addShareToDB(2, 'user1', 'user0', 'user0', 'file', 42, 'userTarget', 0, null, null, $id);
- $user0 = $this->getMock('OCP\IUser');
+ $user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
- $user1 = $this->getMock('OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $group0 = $this->getMock('OCP\IGroup');
+ $group0 = $this->createMock(IGroup::class);
$group0->method('inGroup')->with($user1)->willReturn(true);
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->createMock(Folder::class);
$node->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('user0')->will($this->returnSelf());
@@ -345,8 +350,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $qb->getLastInsertId();
- $ownerPath = $this->getMock('\OCP\Files\Folder');
- $shareOwnerFolder = $this->getMock('\OCP\Files\Folder');
+ $ownerPath = $this->createMock(Folder::class);
+ $shareOwnerFolder = $this->createMock(Folder::class);
$shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
$this->rootFolder
@@ -385,7 +390,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $qb->getLastInsertId();
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id);
$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
@@ -473,7 +478,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
@@ -548,8 +553,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$qb->execute();
- $ownerPath = $this->getMock('\OCP\Files\Folder');
- $ownerFolder = $this->getMock('\OCP\Files\Folder');
+ $ownerPath = $this->createMock(Folder::class);
+ $ownerFolder = $this->createMock(Folder::class);
$ownerFolder->method('getById')->willReturn([$ownerPath]);
$this->rootFolder
@@ -558,7 +563,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $ownerFolder],
]));
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id);
$children = $this->provider->getChildren($share);
@@ -591,15 +596,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testCreateUserShare() {
$share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
- $shareOwner = $this->getMock('OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->WillReturn('shareOwner');
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->createMock(File::class);
$path->method('getId')->willReturn(100);
$path->method('getOwner')->willReturn($shareOwner);
- $ownerFolder = $this->getMock('OCP\Files\Folder');
- $userFolder = $this->getMock('OCP\Files\Folder');
+ $ownerFolder = $this->createMock(Folder::class);
+ $userFolder = $this->createMock(Folder::class);
$this->rootFolder
->method('getUserFolder')
->will($this->returnValueMap([
@@ -639,15 +644,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testCreateGroupShare() {
$share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $path = $this->getMock('\OCP\Files\Folder');
+ $path = $this->createMock(Folder::class);
$path->method('getId')->willReturn(100);
$path->method('getOwner')->willReturn($shareOwner);
- $ownerFolder = $this->getMock('OCP\Files\Folder');
- $userFolder = $this->getMock('OCP\Files\Folder');
+ $ownerFolder = $this->createMock(Folder::class);
+ $userFolder = $this->createMock(Folder::class);
$this->rootFolder
->method('getUserFolder')
->will($this->returnValueMap([
@@ -687,15 +692,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testCreateLinkShare() {
$share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $path = $this->getMock('\OCP\Files\Folder');
+ $path = $this->createMock(Folder::class);
$path->method('getId')->willReturn(100);
$path->method('getOwner')->willReturn($shareOwner);
- $ownerFolder = $this->getMock('OCP\Files\Folder');
- $userFolder = $this->getMock('OCP\Files\Folder');
+ $ownerFolder = $this->createMock(Folder::class);
+ $userFolder = $this->createMock(Folder::class);
$this->rootFolder
->method('getUserFolder')
->will($this->returnValueMap([
@@ -755,7 +760,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->execute();
$id = $qb->getLastInsertId();
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -806,7 +811,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -853,20 +858,20 @@ class DefaultShareProviderTest extends \Test\TestCase {
$groups = [];
foreach(range(0, 100) as $i) {
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group'.$i);
$groups[] = $group;
}
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('sharedWith');
$groups[] = $group;
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('sharedWith');
- $owner = $this->getMock('\OCP\IUser');
+ $owner = $this->createMock(IUser::class);
$owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
+ $initiator = $this->createMock(IUser::class);
$initiator->method('getUID')->willReturn('sharedBy');
$this->userManager->method('get')->willReturnMap([
@@ -877,7 +882,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->groupManager->method('getUserGroups')->with($user)->willReturn($groups);
$this->groupManager->method('get')->with('sharedWith')->willReturn($group);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -944,15 +949,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('sharedWith');
$groups = [$group];
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user');
- $owner = $this->getMock('\OCP\IUser');
+ $owner = $this->createMock(IUser::class);
$owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
+ $initiator = $this->createMock(IUser::class);
$initiator->method('getUID')->willReturn('sharedBy');
$this->userManager->method('get')->willReturnMap([
@@ -963,7 +968,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->groupManager->method('getUserGroups')->with($user)->willReturn($groups);
$this->groupManager->method('get')->with('sharedWith')->willReturn($group);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -986,9 +991,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1',
'file', 43, 'myTarget', 31, null, null, null);
- $user0 = $this->getMock('\OCP\IUser');
+ $user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$this->userManager->method('get')->willReturnMap([
@@ -996,7 +1001,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
['user1', $user1],
]);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(43);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(43)->willReturn([$file]);
@@ -1019,9 +1024,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1',
'file', 43, 'myTarget', 31, null, null, null);
- $user0 = $this->getMock('\OCP\IUser');
+ $user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$this->userManager->method('get')->willReturnMap([
@@ -1029,13 +1034,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
['user1', $user1],
]);
- $group0 = $this->getMock('\OCP\IGroup');
+ $group0 = $this->createMock(IGroup::class);
$group0->method('getGID')->willReturn('group0');
$this->groupManager->method('get')->with('group0')->willReturn($group0);
$this->groupManager->method('getUserGroups')->with($user0)->willReturn([$group0]);
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->createMock(Folder::class);
$node->method('getId')->willReturn(43);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(43)->willReturn([$node]);
@@ -1083,7 +1088,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -1131,7 +1136,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -1180,7 +1185,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $qb->execute());
$id2 = $qb->getLastInsertId();
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
@@ -1223,21 +1228,21 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $stmt);
$id = $qb->getLastInsertId();
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $user2 = $this->getMock('\OCP\IUser');
+ $user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
]));
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group');
$group->method('inGroup')->with($user2)->willReturn(true);
$this->groupManager->method('get')->with('group')->willReturn($group);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1294,21 +1299,21 @@ class DefaultShareProviderTest extends \Test\TestCase {
])->execute();
$this->assertEquals(1, $stmt);
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $user2 = $this->getMock('\OCP\IUser');
+ $user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
]));
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group');
$group->method('inGroup')->with($user2)->willReturn(true);
$this->groupManager->method('get')->with('group')->willReturn($group);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1354,21 +1359,21 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $stmt);
$id = $qb->getLastInsertId();
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $user2 = $this->getMock('\OCP\IUser');
+ $user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
]));
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group');
$group->method('inGroup')->with($user2)->willReturn(false);
$this->groupManager->method('get')->with('group')->willReturn($group);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1395,16 +1400,16 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $stmt);
$id = $qb->getLastInsertId();
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $user2 = $this->getMock('\OCP\IUser');
+ $user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
]));
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1446,17 +1451,17 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $stmt);
$id = $qb->getLastInsertId();
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $user2 = $this->getMock('\OCP\IUser');
+ $user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
- $user3 = $this->getMock('\OCP\IUser');
+ $user3 = $this->createMock(IUser::class);
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
]));
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1487,13 +1492,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $stmt);
$id = $qb->getLastInsertId();
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
]));
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1510,7 +1515,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$users = [];
for($i = 0; $i < 6; $i++) {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user'.$i);
$users['user'.$i] = $user;
}
@@ -1521,14 +1526,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
})
);
- $file1 = $this->getMock('\OCP\Files\File');
+ $file1 = $this->createMock(File::class);
$file1->method('getId')->willReturn(42);
- $file2 = $this->getMock('\OCP\Files\File');
+ $file2 = $this->createMock(File::class);
$file2->method('getId')->willReturn(43);
- $folder1 = $this->getMock('\OCP\Files\Folder');
+ $folder1 = $this->createMock(Folder::class);
$folder1->method('getById')->with(42)->willReturn([$file1]);
- $folder2 = $this->getMock('\OCP\Files\Folder');
+ $folder2 = $this->createMock(Folder::class);
$folder2->method('getById')->with(43)->willReturn([$file2]);
$this->rootFolder->method('getUserFolder')->will($this->returnValueMap([
@@ -1559,7 +1564,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$users = [];
for($i = 0; $i < 6; $i++) {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user'.$i);
$users['user'.$i] = $user;
}
@@ -1570,14 +1575,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
})
);
- $file1 = $this->getMock('\OCP\Files\File');
+ $file1 = $this->createMock(File::class);
$file1->method('getId')->willReturn(42);
- $file2 = $this->getMock('\OCP\Files\File');
+ $file2 = $this->createMock(File::class);
$file2->method('getId')->willReturn(43);
- $folder1 = $this->getMock('\OCP\Files\Folder');
+ $folder1 = $this->createMock(Folder::class);
$folder1->method('getById')->with(42)->willReturn([$file1]);
- $folder2 = $this->getMock('\OCP\Files\Folder');
+ $folder2 = $this->createMock(Folder::class);
$folder2->method('getById')->with(43)->willReturn([$file2]);
$this->rootFolder->method('getUserFolder')->will($this->returnValueMap([
@@ -1608,7 +1613,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$users = [];
for($i = 0; $i < 6; $i++) {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user'.$i);
$users['user'.$i] = $user;
}
@@ -1619,14 +1624,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
})
);
- $file1 = $this->getMock('\OCP\Files\File');
+ $file1 = $this->createMock(File::class);
$file1->method('getId')->willReturn(42);
- $file2 = $this->getMock('\OCP\Files\File');
+ $file2 = $this->createMock(File::class);
$file2->method('getId')->willReturn(43);
- $folder1 = $this->getMock('\OCP\Files\Folder');
+ $folder1 = $this->createMock(Folder::class);
$folder1->method('getById')->with(42)->willReturn([$file1]);
- $folder2 = $this->getMock('\OCP\Files\Folder');
+ $folder2 = $this->createMock(Folder::class);
$folder2->method('getById')->with(43)->willReturn([$file2]);
$this->rootFolder->method('getUserFolder')->will($this->returnValueMap([
@@ -1657,7 +1662,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$users = [];
for($i = 0; $i < 6; $i++) {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user'.$i);
$users['user'.$i] = $user;
}
@@ -1670,7 +1675,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$groups = [];
for($i = 0; $i < 2; $i++) {
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group'.$i);
$groups['group'.$i] = $group;
}
@@ -1681,14 +1686,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
})
);
- $file1 = $this->getMock('\OCP\Files\File');
+ $file1 = $this->createMock(File::class);
$file1->method('getId')->willReturn(42);
- $file2 = $this->getMock('\OCP\Files\File');
+ $file2 = $this->createMock(File::class);
$file2->method('getId')->willReturn(43);
- $folder1 = $this->getMock('\OCP\Files\Folder');
+ $folder1 = $this->createMock(Folder::class);
$folder1->method('getById')->with(42)->willReturn([$file1]);
- $folder2 = $this->getMock('\OCP\Files\Folder');
+ $folder2 = $this->createMock(Folder::class);
$folder2->method('getById')->with(43)->willReturn([$file2]);
$this->rootFolder->method('getUserFolder')->will($this->returnValueMap([
@@ -1726,7 +1731,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$users = [];
for($i = 0; $i < 6; $i++) {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user'.$i);
$users['user'.$i] = $user;
}
@@ -1739,7 +1744,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$groups = [];
for($i = 0; $i < 2; $i++) {
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group'.$i);
$groups['group'.$i] = $group;
}
@@ -1750,14 +1755,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
})
);
- $file1 = $this->getMock('\OCP\Files\File');
+ $file1 = $this->createMock(File::class);
$file1->method('getId')->willReturn(42);
- $file2 = $this->getMock('\OCP\Files\File');
+ $file2 = $this->createMock(File::class);
$file2->method('getId')->willReturn(43);
- $folder1 = $this->getMock('\OCP\Files\Folder');
+ $folder1 = $this->createMock(Folder::class);
$folder1->method('getById')->with(42)->willReturn([$file1]);
- $folder2 = $this->getMock('\OCP\Files\Folder');
+ $folder2 = $this->createMock(Folder::class);
$folder2->method('getById')->with(43)->willReturn([$file2]);
$this->rootFolder->method('getUserFolder')->will($this->returnValueMap([
@@ -1809,9 +1814,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1', 'file',
42, 'mytaret', 31, null, null);
- $user0 = $this->getMock('\OCP\IUser');
+ $user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
$this->userManager->method('get')->will($this->returnValueMap([
@@ -1819,7 +1824,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
['user1', $user1],
]));
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->createMock(File::class);
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
@@ -1838,12 +1843,12 @@ class DefaultShareProviderTest extends \Test\TestCase {
$id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1', 'file',
42, 'mytaret', 31, null, null);
- $user0 = $this->getMock('\OCP\IUser');
+ $user0 = $this->createMock(IUser::class);
$user0->method('getUID')->willReturn('user0');
- $user1 = $this->getMock('\OCP\IUser');
+ $user1 = $this->createMock(IUser::class);
$user1->method('getUID')->willReturn('user1');
- $group0 = $this->getMock('\OCP\IGroup');
+ $group0 = $this->createMock(IGroup::class);
$group0->method('getGID')->willReturn('group0');
$group0->method('inGroup')->with($user0)->willReturn(true);
@@ -1854,7 +1859,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
['user1', $user1],
]));
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->createMock(Folder::class);
$folder->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 689e47d8c52..16ad1b07f89 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -20,8 +20,16 @@
*/
namespace Test\Share20;
+use OC\Files\Mount\MoveableMount;
use OC\HintException;
+use OCP\Files\File;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Node;
+use OCP\Files\Storage;
+use OCP\IGroup;
+use OCP\IUser;
use OCP\IUserManager;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IProviderFactory;
@@ -78,17 +86,17 @@ class ManagerTest extends \Test\TestCase {
public function setUp() {
- $this->logger = $this->getMock('\OCP\ILogger');
- $this->config = $this->getMock('\OCP\IConfig');
- $this->secureRandom = $this->getMock('\OCP\Security\ISecureRandom');
- $this->hasher = $this->getMock('\OCP\Security\IHasher');
- $this->mountManager = $this->getMock('\OCP\Files\Mount\IMountManager');
- $this->groupManager = $this->getMock('\OCP\IGroupManager');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $this->rootFolder = $this->getMock('\OCP\Files\IRootFolder');
- $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcher');
-
- $this->l = $this->getMock('\OCP\IL10N');
+ $this->logger = $this->createMock(ILogger::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->secureRandom = $this->createMock(ISecureRandom::class);
+ $this->hasher = $this->createMock(IHasher::class);
+ $this->mountManager = $this->createMock(IMountManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->rootFolder = $this->createMock(IRootFolder::class);
+ $this->eventDispatcher = $this->createMock(EventDispatcher::class);
+
+ $this->l = $this->createMock(IL10N::class);
$this->l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
return vsprintf($text, $parameters);
@@ -149,10 +157,10 @@ class ManagerTest extends \Test\TestCase {
}
public function dataTestDelete() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('sharedWithUser');
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('sharedWithGroup');
return [
@@ -171,7 +179,7 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['getShareById', 'deleteChildren'])
->getMock();
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->createMock(File::class);
$path->method('getId')->willReturn(1);
$share = $this->manager->newShare();
@@ -328,7 +336,7 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['getShareById'])
->getMock();
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->createMock(File::class);
$path->method('getId')->willReturn(1);
$share1 = $this->manager->newShare();
@@ -451,14 +459,14 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['deleteShare'])
->getMock();
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $child1 = $this->getMock('\OCP\Share\IShare');
+ $child1 = $this->createMock(IShare::class);
$child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $child2 = $this->getMock('\OCP\Share\IShare');
+ $child2 = $this->createMock(IShare::class);
$child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $child3 = $this->getMock('\OCP\Share\IShare');
+ $child3 = $this->createMock(IShare::class);
$child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$shares = [
@@ -487,7 +495,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetShareById() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$this->defaultProvider
->expects($this->once())
@@ -584,7 +592,7 @@ class ManagerTest extends \Test\TestCase {
public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner,
$permissions, $expireDate = null, $password = null) {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn($type);
$share->method('getSharedWith')->willReturn($sharedWith);
@@ -603,8 +611,8 @@ class ManagerTest extends \Test\TestCase {
$user2 = 'user1';
$group0 = 'group0';
- $file = $this->getMock('\OCP\Files\File');
- $node = $this->getMock('\OCP\Files\Node');
+ $file = $this->createMock(File::class);
+ $node = $this->createMock(Node::class);
$data = [
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
@@ -633,7 +641,7 @@ class ManagerTest extends \Test\TestCase {
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
];
- $nonShareAble = $this->getMock('\OCP\Files\Folder');
+ $nonShareAble = $this->createMock(Folder::class);
$nonShareAble->method('isShareable')->willReturn(false);
$nonShareAble->method('getPath')->willReturn('path');
@@ -641,7 +649,7 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $limitedPermssions = $this->getMock('\OCP\Files\File');
+ $limitedPermssions = $this->createMock(File::class);
$limitedPermssions->method('isShareable')->willReturn(true);
$limitedPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$limitedPermssions->method('getPath')->willReturn('path');
@@ -650,14 +658,14 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
- $mount = $this->getMock('OC\Files\Mount\MoveableMount');
+ $mount = $this->createMock(MoveableMount::class);
$limitedPermssions->method('getMountPoint')->willReturn($mount);
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true];
- $nonMoveableMountPermssions = $this->getMock('\OCP\Files\Folder');
+ $nonMoveableMountPermssions = $this->createMock(Folder::class);
$nonMoveableMountPermssions->method('isShareable')->willReturn(true);
$nonMoveableMountPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$nonMoveableMountPermssions->method('getPath')->willReturn('path');
@@ -665,7 +673,7 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Cannot increase permissions of path', false];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Cannot increase permissions of path', false];
- $rootFolder = $this->getMock('\OCP\Files\Folder');
+ $rootFolder = $this->createMock(Folder::class);
$rootFolder->method('isShareable')->willReturn(true);
$rootFolder->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
$rootFolder->method('getPath')->willReturn('myrootfolder');
@@ -674,7 +682,7 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can\'t share your root folder', true];
$data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can\'t share your root folder', true];
- $allPermssions = $this->getMock('\OCP\Files\Folder');
+ $allPermssions = $this->createMock(Folder::class);
$allPermssions->method('isShareable')->willReturn(true);
$allPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
@@ -706,7 +714,7 @@ class ManagerTest extends \Test\TestCase {
['group0', true],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->createMock(Folder::class);
$userFolder->method('getPath')->willReturn('myrootfolder');
$this->rootFolder->method('getUserFolder')->willReturn($userFolder);
@@ -737,7 +745,7 @@ class ManagerTest extends \Test\TestCase {
['user1', true],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->createMock(Folder::class);
$userFolder->method('isSubNode')->with($userFolder)->willReturn(false);
$this->rootFolder->method('getUserFolder')->willReturn($userFolder);
@@ -1000,8 +1008,8 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() {
$share = $this->manager->newShare();
- $sharedBy = $this->getMock('\OCP\IUser');
- $sharedWith = $this->getMock('\OCP\IUser');
+ $sharedBy = $this->createMock(IUser::class);
+ $sharedWith = $this->createMock(IUser::class);
$share->setSharedBy('sharedBy')->setSharedWith('sharedWith');
$this->groupManager
@@ -1030,11 +1038,11 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksShareWithGroupMembersOnlySharedGroup() {
$share = $this->manager->newShare();
- $sharedBy = $this->getMock('\OCP\IUser');
- $sharedWith = $this->getMock('\OCP\IUser');
+ $sharedBy = $this->createMock(IUser::class);
+ $sharedWith = $this->createMock(IUser::class);
$share->setSharedBy('sharedBy')->setSharedWith('sharedWith');
- $path = $this->getMock('\OCP\Files\Node');
+ $path = $this->createMock(Node::class);
$share->setNode($path);
$this->groupManager
@@ -1073,8 +1081,8 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share2 = $this->manager->newShare();
- $sharedWith = $this->getMock('\OCP\IUser');
- $path = $this->getMock('\OCP\Files\Node');
+ $sharedWith = $this->createMock(IUser::class);
+ $path = $this->createMock(Node::class);
$share->setSharedWith('sharedWith')->setNode($path)
->setProviderId('foo')->setId('bar');
@@ -1097,12 +1105,12 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksIdenticalPathSharedViaGroup() {
$share = $this->manager->newShare();
- $sharedWith = $this->getMock('\OCP\IUser');
+ $sharedWith = $this->createMock(IUser::class);
$sharedWith->method('getUID')->willReturn('sharedWith');
$this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
- $path = $this->getMock('\OCP\Files\Node');
+ $path = $this->createMock(Node::class);
$share->setSharedWith('sharedWith')
->setNode($path)
@@ -1117,7 +1125,7 @@ class ManagerTest extends \Test\TestCase {
->setId('baz')
->setSharedWith('group');
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('inGroup')
->with($sharedWith)
->willReturn(true);
@@ -1134,8 +1142,8 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksIdenticalPathNotSharedWithUser() {
$share = $this->manager->newShare();
- $sharedWith = $this->getMock('\OCP\IUser');
- $path = $this->getMock('\OCP\Files\Node');
+ $sharedWith = $this->createMock(IUser::class);
+ $path = $this->createMock(Node::class);
$share->setSharedWith('sharedWith')
->setNode($path)
->setShareOwner('shareOwner')
@@ -1150,7 +1158,7 @@ class ManagerTest extends \Test\TestCase {
->setProviderId('foo')
->setId('baz');
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$group->method('inGroup')
->with($sharedWith)
->willReturn(false);
@@ -1190,8 +1198,8 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() {
$share = $this->manager->newShare();
- $user = $this->getMock('\OCP\IUser');
- $group = $this->getMock('\OCP\IGroup');
+ $user = $this->createMock(IUser::class);
+ $group = $this->createMock(IGroup::class);
$share->setSharedBy('user')->setSharedWith('group');
$group->method('inGroup')->with($user)->willReturn(false);
@@ -1212,8 +1220,8 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() {
$share = $this->manager->newShare();
- $user = $this->getMock('\OCP\IUser');
- $group = $this->getMock('\OCP\IGroup');
+ $user = $this->createMock(IUser::class);
+ $group = $this->createMock(IGroup::class);
$share->setSharedBy('user')->setSharedWith('group');
$this->userManager->method('get')->with('user')->willReturn($user);
@@ -1221,7 +1229,7 @@ class ManagerTest extends \Test\TestCase {
$group->method('inGroup')->with($user)->willReturn(true);
- $path = $this->getMock('\OCP\Files\Node');
+ $path = $this->createMock(Node::class);
$share->setNode($path);
$this->defaultProvider->method('getSharesByPath')
@@ -1245,7 +1253,7 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksPathAlreadySharedWithSameGroup() {
$share = $this->manager->newShare();
- $path = $this->getMock('\OCP\Files\Node');
+ $path = $this->createMock(Node::class);
$share->setSharedWith('sharedWith')
->setNode($path)
->setProviderId('foo')
@@ -1274,7 +1282,7 @@ class ManagerTest extends \Test\TestCase {
$share->setSharedWith('sharedWith');
- $path = $this->getMock('\OCP\Files\Node');
+ $path = $this->createMock(Node::class);
$share->setNode($path);
$share2 = $this->manager->newShare();
@@ -1381,11 +1389,11 @@ class ManagerTest extends \Test\TestCase {
* @expectedExceptionMessage Path contains files shared with you
*/
public function testPathCreateChecksContainsSharedMount() {
- $path = $this->getMock('\OCP\Files\Folder');
+ $path = $this->createMock(Folder::class);
$path->method('getPath')->willReturn('path');
- $mount = $this->getMock('\OCP\Files\Mount\IMountPoint');
- $storage = $this->getMock('\OCP\Files\Storage');
+ $mount = $this->createMock(IMountPoint::class);
+ $storage = $this->createMock(Storage::class);
$mount->method('getStorage')->willReturn($storage);
$storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(true);
@@ -1395,11 +1403,11 @@ class ManagerTest extends \Test\TestCase {
}
public function testPathCreateChecksContainsNoSharedMount() {
- $path = $this->getMock('\OCP\Files\Folder');
+ $path = $this->createMock(Folder::class);
$path->method('getPath')->willReturn('path');
- $mount = $this->getMock('\OCP\Files\Mount\IMountPoint');
- $storage = $this->getMock('\OCP\Files\Storage');
+ $mount = $this->createMock(IMountPoint::class);
+ $storage = $this->createMock(Storage::class);
$mount->method('getStorage')->willReturn($storage);
$storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(false);
@@ -1409,7 +1417,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testPathCreateChecksContainsNoFolder() {
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->createMock(File::class);
$this->invokePrivate($this->manager, 'pathCreateChecks', [$path]);
}
@@ -1454,7 +1462,7 @@ class ManagerTest extends \Test\TestCase {
* @param bool $expected
*/
public function testIsSharingDisabledForUser($excludeGroups, $groupList, $setList, $groupIds, $expected) {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->createMock(IUser::class);
$this->config->method('getAppValue')
->will($this->returnValueMap([
@@ -1535,11 +1543,11 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'userCreateChecks', 'pathCreateChecks'])
->getMock();
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $storage = $this->getMock('\OCP\Files\Storage');
- $path = $this->getMock('\OCP\Files\File');
+ $storage = $this->createMock(Storage::class);
+ $path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
$path->method('getStorage')->willReturn($storage);
@@ -1588,11 +1596,11 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'groupCreateChecks', 'pathCreateChecks'])
->getMock();
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $storage = $this->getMock('\OCP\Files\Storage');
- $path = $this->getMock('\OCP\Files\File');
+ $storage = $this->createMock(Storage::class);
+ $path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
$path->method('getStorage')->willReturn($storage);
@@ -1649,11 +1657,11 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $storage = $this->getMock('\OCP\Files\Storage');
- $path = $this->getMock('\OCP\Files\File');
+ $storage = $this->createMock(Storage::class);
+ $path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
$path->method('getId')->willReturn(1);
@@ -1775,11 +1783,11 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $storage = $this->getMock('\OCP\Files\Storage');
- $path = $this->getMock('\OCP\Files\File');
+ $storage = $this->createMock(Storage::class);
+ $path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
$path->method('getStorage')->willReturn($storage);
@@ -1831,28 +1839,28 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'userCreateChecks', 'pathCreateChecks'])
->getMock();
- $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(true);
- $storage2 = $this->getMock('\OCP\Files\Storage');
+ $storage2 = $this->createMock(Storage::class);
$storage2->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->createMock(File::class);
$path->expects($this->never())->method('getOwner');
$path->method('getName')->willReturn('target');
$path->method('getStorage')->willReturn($storage);
- $parent = $this->getMock('\OCP\Files\Folder');
+ $parent = $this->createMock(Folder::class);
$parent->method('getStorage')->willReturn($storage);
- $parentParent = $this->getMock('\OCP\Files\Folder');
+ $parentParent = $this->createMock(Folder::class);
$parentParent->method('getStorage')->willReturn($storage2);
$parentParent->method('getOwner')->willReturn($shareOwner);
@@ -1901,7 +1909,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetSharesBy() {
$share = $this->manager->newShare();
- $node = $this->getMock('OCP\Files\Folder');
+ $node = $this->createMock(Folder::class);
$this->defaultProvider->expects($this->once())
->method('getSharesBy')
@@ -1962,7 +1970,7 @@ class ManagerTest extends \Test\TestCase {
$shares2[] = clone $shares[$i];
}
- $node = $this->getMock('OCP\Files\File');
+ $node = $this->createMock(File::class);
/*
* Simulate the getSharesBy call.
@@ -2002,7 +2010,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetShareByToken() {
- $factory = $this->getMock('\OCP\Share\IProviderFactory');
+ $factory = $this->createMock(IProviderFactory::class);
$manager = new Manager(
$this->logger,
@@ -2018,7 +2026,7 @@ class ManagerTest extends \Test\TestCase {
$this->eventDispatcher
);
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$factory->expects($this->once())
->method('getProviderForType')
@@ -2035,7 +2043,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetShareByTokenWithException() {
- $factory = $this->getMock('\OCP\Share\IProviderFactory');
+ $factory = $this->createMock(IProviderFactory::class);
$manager = new Manager(
$this->logger,
@@ -2051,7 +2059,7 @@ class ManagerTest extends \Test\TestCase {
$this->eventDispatcher
);
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$factory->expects($this->at(0))
->method('getProviderForType')
@@ -2137,13 +2145,13 @@ class ManagerTest extends \Test\TestCase {
}
public function testCheckPasswordNoLinkShare() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$this->assertFalse($this->manager->checkPassword($share, 'password'));
}
public function testCheckPasswordNoPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$this->assertFalse($this->manager->checkPassword($share, 'password'));
@@ -2152,7 +2160,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testCheckPasswordInvalidPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getPassword')->willReturn('password');
@@ -2162,7 +2170,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testCheckPasswordValidPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->createMock(IShare::class);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getPassword')->willReturn('passwordHash');
@@ -2294,7 +2302,7 @@ class ManagerTest extends \Test\TestCase {
->setSharedWith('origUser')
->setPermissions(1);
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->createMock(File::class);
$node->method('getId')->willReturn(100);
$node->method('getPath')->willReturn('/newUser/files/myPath');
@@ -2357,7 +2365,7 @@ class ManagerTest extends \Test\TestCase {
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->createMock(File::class);
$share = $this->manager->newShare();
$share->setProviderId('foo')
@@ -2453,7 +2461,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
- $recipient = $this->getMock('\OCP\IUser');
+ $recipient = $this->createMock(IUser::class);
$this->manager->moveShare($share, $recipient);
}
@@ -2492,10 +2500,10 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
- $sharedWith = $this->getMock('\OCP\IGroup');
+ $sharedWith = $this->createMock(IGroup::class);
$share->setSharedWith('shareWith');
- $recipient = $this->getMock('\OCP\IUser');
+ $recipient = $this->createMock(IUser::class);
$sharedWith->method('inGroup')->with($recipient)->willReturn(false);
$this->groupManager->method('get')->with('shareWith')->willReturn($sharedWith);
@@ -2510,10 +2518,10 @@ class ManagerTest extends \Test\TestCase {
->setId('42')
->setProviderId('foo');
- $group = $this->getMock('\OCP\IGroup');
+ $group = $this->createMock(IGroup::class);
$share->setSharedWith('group');
- $recipient = $this->getMock('\OCP\IUser');
+ $recipient = $this->createMock(IUser::class);
$group->method('inGroup')->with($recipient)->willReturn(true);
$this->groupManager->method('get')->with('group')->willReturn($group);