Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-01 17:37:29 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-01 17:37:29 +0300
commite2805f02aa51c602c581bd4f09b99dd791a42df4 (patch)
tree4ea194f47aa315874c2aac31c30dbdb14110539b /tests
parent2b4b3b1986e58305c08941f77a693a80cc3d5b85 (diff)
parent52b679a2d6f6b273f46334b15534ab312f974a1a (diff)
Merge branch 'master' into autocomplete-gui
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/AvatarControllerTest.php10
-rw-r--r--tests/Core/Controller/ChangePasswordControllerTest.php9
-rw-r--r--tests/Core/Controller/LostControllerTest.php6
-rw-r--r--tests/Core/Middleware/TwoFactorMiddlewareTest.php6
-rw-r--r--tests/Settings/Controller/AdminSettingsControllerTest.php9
-rw-r--r--tests/Settings/Controller/CertificateControllerTest.php4
-rw-r--r--tests/Settings/Controller/CheckSetupControllerTest.php12
-rw-r--r--tests/Settings/Controller/EncryptionControllerTest.php28
-rw-r--r--tests/Settings/Controller/GroupsControllerTest.php24
-rw-r--r--tests/Settings/Controller/UsersControllerTest.php96
-rw-r--r--tests/Settings/Middleware/SubadminMiddlewareTest.php4
-rw-r--r--tests/acceptance/features/app-files.feature16
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php48
-rwxr-xr-xtests/acceptance/run.sh2
-rw-r--r--tests/lib/APITest.php4
-rw-r--r--tests/lib/Accounts/AccountsManagerTest.php12
-rw-r--r--tests/lib/Activity/ManagerTest.php5
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php2
-rw-r--r--tests/lib/AppFramework/Controller/ApiControllerTest.php3
-rw-r--r--tests/lib/AppFramework/Controller/ControllerTest.php3
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php13
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php3
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php3
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php10
-rw-r--r--tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php3
-rw-r--r--tests/lib/AppFramework/Routing/RoutingTest.php11
-rw-r--r--tests/lib/BackgroundJob/JobTest.php4
-rw-r--r--tests/lib/CapabilitiesManagerTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchResultTest.php105
-rw-r--r--tests/lib/DB/MigratorTest.php39
-rw-r--r--tests/lib/DateTimeFormatterTest.php9
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php21
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php3
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php6
-rw-r--r--tests/lib/Encryption/UpdateTest.php6
-rw-r--r--tests/lib/Encryption/UtilTest.php6
-rw-r--r--tests/lib/FileChunkingTest.php2
-rw-r--r--tests/lib/Files/Node/FolderTest.php6
-rw-r--r--tests/lib/Files/Node/NodeTest.php15
-rw-r--r--tests/lib/Files/Node/RootTest.php16
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php11
-rw-r--r--tests/lib/Files/Storage/Wrapper/QuotaTest.php2
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php3
-rw-r--r--tests/lib/Files/Type/DetectionTest.php21
-rw-r--r--tests/lib/Files/ViewTest.php4
-rw-r--r--tests/lib/Group/GroupTest.php6
-rw-r--r--tests/lib/HTTPHelperTest.php3
-rw-r--r--tests/lib/LoggerTest.php26
-rw-r--r--tests/lib/Memcache/FactoryTest.php6
-rw-r--r--tests/lib/Migration/BackgroundRepairTest.php2
-rw-r--r--tests/lib/Notification/ManagerTest.php53
-rw-r--r--tests/lib/Repair/CleanTagsTest.php3
-rw-r--r--tests/lib/Repair/RepairInvalidSharesTest.php3
-rw-r--r--tests/lib/Repair/RepairMimeTypesTest.php2
-rw-r--r--tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php2
-rw-r--r--tests/lib/Security/CertificateManagerTest.php3
-rw-r--r--tests/lib/Security/HasherTest.php5
-rw-r--r--tests/lib/Security/TrustedDomainHelperTest.php2
-rw-r--r--tests/lib/Session/CryptoWrappingTest.php3
-rw-r--r--tests/lib/Settings/Admin/AdditionalTest.php2
-rw-r--r--tests/lib/Settings/Admin/EncryptionTest.php2
-rw-r--r--tests/lib/Settings/Admin/ServerTest.php4
-rw-r--r--tests/lib/Settings/Admin/SharingTest.php2
-rw-r--r--tests/lib/Settings/Admin/TipsTricksTest.php2
-rw-r--r--tests/lib/SystemTag/SystemTagManagerTest.php7
-rw-r--r--tests/lib/TestCase.php2
-rw-r--r--tests/lib/Updater/VersionCheckTest.php5
-rw-r--r--tests/lib/User/ManagerTest.php2
-rw-r--r--tests/lib/User/SessionTest.php8
-rw-r--r--tests/lib/User/UserTest.php2
-rw-r--r--tests/lib/UtilTest.php6
72 files changed, 547 insertions, 245 deletions
diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php
index 1a1f1130480..de568438022 100644
--- a/tests/Core/Controller/AvatarControllerTest.php
+++ b/tests/Core/Controller/AvatarControllerTest.php
@@ -85,16 +85,16 @@ class AvatarControllerTest extends \Test\TestCase {
$this->avatarManager = $this->getMockBuilder('OCP\IAvatarManager')->getMock();
$this->cache = $this->getMockBuilder('OCP\ICache')
->disableOriginalConstructor()->getMock();
- $this->l = $this->getMockBuilder('OCP\IL10N')->getMock();
+ $this->l = $this->getMockBuilder(IL10N::class)->getMock();
$this->l->method('t')->will($this->returnArgument(0));
- $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock();
- $this->request = $this->getMockBuilder('OCP\IRequest')->getMock();
+ $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
+ $this->request = $this->getMockBuilder(IRequest::class)->getMock();
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
- $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock();
+ $this->logger = $this->getMockBuilder(ILogger::class)->getMock();
$this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock();
$this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock();
- $this->userMock = $this->getMockBuilder('OCP\IUser')->getMock();
+ $this->userMock = $this->getMockBuilder(IUser::class)->getMock();
$this->avatarController = new AvatarController(
'core',
diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php
index ea3abb58e2f..851b5bd6c76 100644
--- a/tests/Core/Controller/ChangePasswordControllerTest.php
+++ b/tests/Core/Controller/ChangePasswordControllerTest.php
@@ -29,6 +29,7 @@ use OCP\AppFramework\Http\JSONResponse;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\IUser;
use OCP\IUserManager;
class ChangePasswordControllerTest extends \Test\TestCase {
@@ -91,7 +92,7 @@ class ChangePasswordControllerTest extends \Test\TestCase {
}
public function testChangePersonalPasswordCommonPassword() {
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$this->userManager->expects($this->once())
->method('checkPassword')
->with($this->userId, 'old')
@@ -114,7 +115,7 @@ class ChangePasswordControllerTest extends \Test\TestCase {
}
public function testChangePersonalPasswordNoNewPassword() {
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$this->userManager->expects($this->once())
->method('checkPassword')
->with($this->userId, 'old')
@@ -130,7 +131,7 @@ class ChangePasswordControllerTest extends \Test\TestCase {
}
public function testChangePersonalPasswordCantSetPassword() {
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$this->userManager->expects($this->once())
->method('checkPassword')
->with($this->userId, 'old')
@@ -150,7 +151,7 @@ class ChangePasswordControllerTest extends \Test\TestCase {
}
public function testChangePersonalPassword() {
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$this->userManager->expects($this->once())
->method('checkPassword')
->with($this->userId, 'old')
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php
index 196b1da352b..1e51de649e3 100644
--- a/tests/Core/Controller/LostControllerTest.php
+++ b/tests/Core/Controller/LostControllerTest.php
@@ -105,9 +105,9 @@ class LostControllerTest extends \Test\TestCase {
}));
$this->defaults = $this->getMockBuilder('\OCP\Defaults')
->disableOriginalConstructor()->getMock();
- $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
+ $this->userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()->getMock();
- $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()->getMock();
$this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer')
->disableOriginalConstructor()->getMock();
@@ -115,7 +115,7 @@ class LostControllerTest extends \Test\TestCase {
->disableOriginalConstructor()->getMock();
$this->timeFactory = $this->getMockBuilder('\OCP\AppFramework\Utility\ITimeFactory')
->disableOriginalConstructor()->getMock();
- $this->request = $this->getMockBuilder('OCP\IRequest')
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()->getMock();
$this->encryptionManager = $this->getMockBuilder(IManager::class)
->disableOriginalConstructor()->getMock();
diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
index 56022c78bdd..eb72b3e6796 100644
--- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php
+++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
@@ -22,8 +22,10 @@
namespace Test\Core\Middleware;
+use OC\Authentication\TwoFactorAuth\Manager;
use OC\Core\Middleware\TwoFactorMiddleware;
use OC\AppFramework\Http\Request;
+use OC\User\Session;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Utility\IControllerMethodReflector;
use OCP\IConfig;
@@ -51,10 +53,10 @@ class TwoFactorMiddlewareTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
+ $this->twoFactorManager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMockBuilder('\OC\User\Session')
+ $this->userSession = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()
->getMock();
$this->session = $this->createMock(ISession::class);
diff --git a/tests/Settings/Controller/AdminSettingsControllerTest.php b/tests/Settings/Controller/AdminSettingsControllerTest.php
index 51357f67a2d..d5650b397fa 100644
--- a/tests/Settings/Controller/AdminSettingsControllerTest.php
+++ b/tests/Settings/Controller/AdminSettingsControllerTest.php
@@ -25,6 +25,7 @@ namespace Tests\Settings\Controller;
use OC\Settings\Admin\TipsTricks;
use OC\Settings\Controller\AdminSettingsController;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\Settings\IManager;
@@ -52,9 +53,9 @@ class AdminSettingsControllerTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
- $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock();
- $this->settingsManager = $this->getMockBuilder('\OCP\Settings\IManager')->getMock();
+ $this->request = $this->getMockBuilder(IRequest::class)->getMock();
+ $this->navigationManager = $this->getMockBuilder(INavigationManager::class)->getMock();
+ $this->settingsManager = $this->getMockBuilder(IManager::class)->getMock();
$this->adminSettingsController = new AdminSettingsController(
'settings',
@@ -87,7 +88,7 @@ class AdminSettingsControllerTest extends TestCase {
->expects($this->once())
->method('getAdminSettings')
->with('test')
- ->willReturn([5 => new TipsTricks($this->getMockBuilder('\OCP\IConfig')->getMock())]);
+ ->willReturn([5 => new TipsTricks($this->getMockBuilder(IConfig::class)->getMock())]);
$expected = new TemplateResponse('settings', 'settings/frame', ['forms' => ['personal' => [], 'admin' => []], 'content' => '']);
$this->assertEquals($expected, $this->adminSettingsController->index('test'));
diff --git a/tests/Settings/Controller/CertificateControllerTest.php b/tests/Settings/Controller/CertificateControllerTest.php
index 48d34a1542b..fb5076dc012 100644
--- a/tests/Settings/Controller/CertificateControllerTest.php
+++ b/tests/Settings/Controller/CertificateControllerTest.php
@@ -51,10 +51,10 @@ class CertificateControllerTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
+ $this->request = $this->getMockBuilder(IRequest::class)->getMock();
$this->certificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock();
$this->systemCertificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock();
- $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
+ $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
$this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock();
$this->certificateController = $this->getMockBuilder('OC\Settings\Controller\CertificateController')
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php
index 74eee3fea41..f0e203e714b 100644
--- a/tests/Settings/Controller/CheckSetupControllerTest.php
+++ b/tests/Settings/Controller/CheckSetupControllerTest.php
@@ -64,17 +64,17 @@ class CheckSetupControllerTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->request = $this->getMockBuilder('\OCP\IRequest')
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()->getMock();
- $this->config = $this->getMockBuilder('\OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock();
- $this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService')
+ $this->clientService = $this->getMockBuilder(IClientService::class)
->disableOriginalConstructor()->getMock();
$this->util = $this->getMockBuilder('\OC_Util')
->disableOriginalConstructor()->getMock();
- $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()->getMock();
- $this->l10n = $this->getMockBuilder('\OCP\IL10N')
+ $this->l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()->getMock();
$this->l10n->expects($this->any())
->method('t')
@@ -83,7 +83,7 @@ class CheckSetupControllerTest extends TestCase {
}));
$this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
->disableOriginalConstructor()->getMock();
- $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
+ $this->logger = $this->getMockBuilder(ILogger::class)->getMock();
$this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
->setConstructorArgs([
'settings',
diff --git a/tests/Settings/Controller/EncryptionControllerTest.php b/tests/Settings/Controller/EncryptionControllerTest.php
index bbc2d7b6599..b15a71fc016 100644
--- a/tests/Settings/Controller/EncryptionControllerTest.php
+++ b/tests/Settings/Controller/EncryptionControllerTest.php
@@ -24,11 +24,14 @@ namespace Tests\Settings\Controller;
use OC\DB\Connection;
use OC\Files\View;
use OC\Settings\Controller\EncryptionController;
+use OCP\App\IAppManager;
+use OCA\Encryption\Migration;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserManager;
+use OCP\UserInterface;
use Test\TestCase;
/**
@@ -51,32 +54,36 @@ class EncryptionControllerTest extends TestCase {
private $view;
/** @var ILogger */
private $logger;
+ /** @var IAppManager */
+ private $appManager;
/** @var EncryptionController */
private $encryptionController;
public function setUp() {
parent::setUp();
- $this->request = $this->getMockBuilder('\\OCP\\IRequest')
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()->getMock();
- $this->l10n = $this->getMockBuilder('\\OCP\\IL10N')
+ $this->l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()->getMock();
$this->l10n->expects($this->any())
->method('t')
->will($this->returnCallback(function($message, array $replace) {
return vsprintf($message, $replace);
}));
- $this->config = $this->getMockBuilder('\\OCP\\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock();
- $this->connection = $this->getMockBuilder('\\OC\\DB\\Connection')
+ $this->connection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()->getMock();
- $this->userManager = $this->getMockBuilder('\\OCP\\IUserManager')
+ $this->userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()->getMock();
- $this->view = $this->getMockBuilder('\\OC\\Files\\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
- $this->logger = $this->getMockBuilder('\\OCP\\ILogger')
+ $this->logger = $this->getMockBuilder(ILogger::class)
+ ->disableOriginalConstructor()->getMock();
+ $this->appManager = $this->getMockBuilder('\\OCP\\App\\IAppManager')
->disableOriginalConstructor()->getMock();
- $this->encryptionController = $this->getMockBuilder('\\OC\\Settings\\Controller\\EncryptionController')
+ $this->encryptionController = $this->getMockBuilder(EncryptionController::class)
->setConstructorArgs([
'settings',
$this->request,
@@ -86,6 +93,7 @@ class EncryptionControllerTest extends TestCase {
$this->userManager,
$this->view,
$this->logger,
+ $this->appManager,
])
->setMethods(['getMigration'])
->getMock();
@@ -95,7 +103,7 @@ class EncryptionControllerTest extends TestCase {
// we need to be able to autoload the class we're mocking
\OC_App::registerAutoloading('encryption', \OC_App::getAppPath('encryption'));
- $migration = $this->getMockBuilder('\\OCA\\Encryption\\Migration')
+ $migration = $this->getMockBuilder(Migration::class)
->disableOriginalConstructor()->getMock();
$this->encryptionController
->expects($this->once())
@@ -108,7 +116,7 @@ class EncryptionControllerTest extends TestCase {
$migration
->expects($this->once())
->method('updateDB');
- $backend = $this->getMockBuilder('\OCP\UserInterface')
+ $backend = $this->getMockBuilder(UserInterface::class)
->getMock();
$this->userManager
->expects($this->once())
diff --git a/tests/Settings/Controller/GroupsControllerTest.php b/tests/Settings/Controller/GroupsControllerTest.php
index 340b39bf9dd..ecbfa9ea05e 100644
--- a/tests/Settings/Controller/GroupsControllerTest.php
+++ b/tests/Settings/Controller/GroupsControllerTest.php
@@ -10,8 +10,10 @@
namespace Tests\Settings\Controller;
+use OC\Group\Group;
use OC\Group\MetaData;
use OC\Settings\Controller\GroupsController;
+use OC\User\User;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\IGroupManager;
@@ -59,7 +61,7 @@ class GroupsControllerTest extends \Test\TestCase {
* to test for subadmins. Thus the test always assumes you have admin permissions...
*/
public function testIndexSortByName() {
- $firstGroup = $this->getMockBuilder('\OC\Group\Group')
+ $firstGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$firstGroup
->method('getGID')
@@ -67,7 +69,7 @@ class GroupsControllerTest extends \Test\TestCase {
$firstGroup
->method('count')
->will($this->returnValue(12));
- $secondGroup = $this->getMockBuilder('\OC\Group\Group')
+ $secondGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$secondGroup
->method('getGID')
@@ -75,7 +77,7 @@ class GroupsControllerTest extends \Test\TestCase {
$secondGroup
->method('count')
->will($this->returnValue(25));
- $thirdGroup = $this->getMockBuilder('\OC\Group\Group')
+ $thirdGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$thirdGroup
->method('getGID')
@@ -83,7 +85,7 @@ class GroupsControllerTest extends \Test\TestCase {
$thirdGroup
->method('count')
->will($this->returnValue(14));
- $fourthGroup = $this->getMockBuilder('\OC\Group\Group')
+ $fourthGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$fourthGroup
->method('getGID')
@@ -98,7 +100,7 @@ class GroupsControllerTest extends \Test\TestCase {
$groups[] = $thirdGroup;
$groups[] = $fourthGroup;
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -151,7 +153,7 @@ class GroupsControllerTest extends \Test\TestCase {
* to test for subadmins. Thus the test always assumes you have admin permissions...
*/
public function testIndexSortbyCount() {
- $firstGroup = $this->getMockBuilder('\OC\Group\Group')
+ $firstGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$firstGroup
->method('getGID')
@@ -159,7 +161,7 @@ class GroupsControllerTest extends \Test\TestCase {
$firstGroup
->method('count')
->will($this->returnValue(12));
- $secondGroup = $this->getMockBuilder('\OC\Group\Group')
+ $secondGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$secondGroup
->method('getGID')
@@ -167,7 +169,7 @@ class GroupsControllerTest extends \Test\TestCase {
$secondGroup
->method('count')
->will($this->returnValue(25));
- $thirdGroup = $this->getMockBuilder('\OC\Group\Group')
+ $thirdGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$thirdGroup
->method('getGID')
@@ -175,7 +177,7 @@ class GroupsControllerTest extends \Test\TestCase {
$thirdGroup
->method('count')
->will($this->returnValue(14));
- $fourthGroup = $this->getMockBuilder('\OC\Group\Group')
+ $fourthGroup = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$fourthGroup
->method('getGID')
@@ -190,7 +192,7 @@ class GroupsControllerTest extends \Test\TestCase {
$groups[] = $thirdGroup;
$groups[] = $fourthGroup;
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -302,7 +304,7 @@ class GroupsControllerTest extends \Test\TestCase {
}
public function testDestroySuccessful() {
- $group = $this->getMockBuilder('\OC\Group\Group')
+ $group = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$this->groupManager
->expects($this->once())
diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php
index cd08c834147..15c18fb7f08 100644
--- a/tests/Settings/Controller/UsersControllerTest.php
+++ b/tests/Settings/Controller/UsersControllerTest.php
@@ -11,9 +11,11 @@
namespace Tests\Settings\Controller;
use OC\Accounts\AccountManager;
+use OC\Group\Group;
use OC\Group\Manager;
use OC\Settings\Controller\UsersController;
use OC\Settings\Mailer\NewUserMailHelper;
+use OC\SubAdmin;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -326,7 +328,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('bar')
->will($this->returnValue($bar));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -546,19 +548,19 @@ class UsersControllerTest extends \Test\TestCase {
->with('admin')
->will($this->returnValue($admin));
- $subgroup1 = $this->getMockBuilder('\OCP\IGroup')
+ $subgroup1 = $this->getMockBuilder(IGroup::class)
->disableOriginalConstructor()
->getMock();
$subgroup1->expects($this->any())
->method('getGID')
->will($this->returnValue('SubGroup1'));
- $subgroup2 = $this->getMockBuilder('\OCP\IGroup')
+ $subgroup2 = $this->getMockBuilder(IGroup::class)
->disableOriginalConstructor()
->getMock();
$subgroup2->expects($this->any())
->method('getGID')
->will($this->returnValue('SubGroup2'));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -746,7 +748,7 @@ class UsersControllerTest extends \Test\TestCase {
->method('getUserGroupIds')
->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users')));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->any())
@@ -865,7 +867,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('')
->will($this->returnValue([$user]));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -951,7 +953,7 @@ class UsersControllerTest extends \Test\TestCase {
->method('createUser')
->will($this->onConsecutiveCalls($user));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -1006,13 +1008,13 @@ class UsersControllerTest extends \Test\TestCase {
$user->expects($this->any())
->method('isEnabled')
->willReturn(true);
- $existingGroup = $this->getMockBuilder('\OCP\IGroup')
+ $existingGroup = $this->getMockBuilder(IGroup::class)
->disableOriginalConstructor()->getMock();
$existingGroup
->expects($this->once())
->method('addUser')
->with($user);
- $newGroup = $this->getMockBuilder('\OCP\IGroup')
+ $newGroup = $this->getMockBuilder(IGroup::class)
->disableOriginalConstructor()->getMock();
$newGroup
->expects($this->once())
@@ -1038,7 +1040,7 @@ class UsersControllerTest extends \Test\TestCase {
->with($user)
->will($this->onConsecutiveCalls(array('NewGroup', 'ExistingGroup')));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -1358,7 +1360,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('UserToDelete')
->will($this->returnValue($toDeleteUser));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1441,7 +1443,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('UserToDelete')
->will($this->returnValue($toDeleteUser));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1487,7 +1489,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('UserToDelete')
->will($this->returnValue($toDeleteUser));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1571,7 +1573,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->once())
->method('createUser')
->will($this->onConsecutiveCalls($user));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1637,7 +1639,7 @@ class UsersControllerTest extends \Test\TestCase {
list($user, $expectedResult) = $this->mockUser();
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1684,7 +1686,7 @@ class UsersControllerTest extends \Test\TestCase {
)
->will($this->returnValue('1'));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1722,7 +1724,7 @@ class UsersControllerTest extends \Test\TestCase {
// without the master key enabled we use per-user keys -> restore is disabled
$expectedResult['isRestoreDisabled'] = !$masterKeyEnabled;
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1779,7 +1781,7 @@ class UsersControllerTest extends \Test\TestCase {
$expectedResult['isRestoreDisabled'] = true;
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1801,7 +1803,7 @@ class UsersControllerTest extends \Test\TestCase {
list($user, $expectedResult) = $this->mockUser();
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
@@ -1853,21 +1855,21 @@ class UsersControllerTest extends \Test\TestCase {
->method('getUser')
->will($this->returnValue($user));
- $group1 = $this->getMockBuilder('\OC\Group\Group')
+ $group1 = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$group1
->expects($this->once())
->method('getUsers')
->will($this->returnValue(['foo' => 'M. Foo', 'admin' => 'S. Admin']));
- $group2 = $this->getMockBuilder('\OC\Group\Group')
+ $group2 = $this->getMockBuilder(Group::class)
->disableOriginalConstructor()->getMock();
$group2
->expects($this->once())
->method('getUsers')
->will($this->returnValue(['bar' => 'B. Ar']));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -1971,7 +1973,7 @@ class UsersControllerTest extends \Test\TestCase {
->willReturn($editUser);
$this->accountManager->expects($this->any())->method('getUser')->willReturn([]);
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -2036,7 +2038,7 @@ class UsersControllerTest extends \Test\TestCase {
->with($user->getUID())
->willReturn($user);
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -2437,7 +2439,7 @@ class UsersControllerTest extends \Test\TestCase {
->method('createUser')
->will($this->onConsecutiveCalls($user));
- $subadmin = $this->getMockBuilder('\OC\SubAdmin')
+ $subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
@@ -2576,7 +2578,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testDisableUserFailsDueSameUser() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2599,7 +2601,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testDisableUserFailsDueNoAdminAndNoSubadmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2608,7 +2610,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(2))
->method('getUser')
->will($this->returnValue($user));
- $user2 = $this->getMockBuilder('\OC\User\User')
+ $user2 = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user2->expects($this->never())
->method('setEnabled');
@@ -2618,7 +2620,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('abc')
->willReturn($user2);
- $subadmin = $this->createMock('\OC\SubAdmin');
+ $subadmin = $this->createMock(SubAdmin::class);
$subadmin->expects($this->once())
->method('isUserAccessible')
->will($this->returnValue(false));
@@ -2641,7 +2643,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testDisableUserFailsDueNoUser() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2674,7 +2676,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testDisableUserFailsDueNoUserForSubAdmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2707,7 +2709,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testDisableUserSuccessForAdmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2716,7 +2718,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(1))
->method('getUser')
->will($this->returnValue($user));
- $user2 = $this->getMockBuilder('\OC\User\User')
+ $user2 = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user2->expects($this->once())
->method('setEnabled')
@@ -2745,7 +2747,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testDisableUserSuccessForSubAdmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2754,7 +2756,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(2))
->method('getUser')
->will($this->returnValue($user));
- $user2 = $this->getMockBuilder('\OC\User\User')
+ $user2 = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user2->expects($this->once())
->method('setEnabled');
@@ -2764,7 +2766,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('abc')
->willReturn($user2);
- $subadmin = $this->createMock('\OC\SubAdmin');
+ $subadmin = $this->createMock(SubAdmin::class);
$subadmin->expects($this->once())
->method('isUserAccessible')
->will($this->returnValue(true));
@@ -2787,7 +2789,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testEnableUserFailsDueSameUser() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2810,7 +2812,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testEnableUserFailsDueNoAdminAndNoSubadmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2819,7 +2821,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(2))
->method('getUser')
->will($this->returnValue($user));
- $user2 = $this->getMockBuilder('\OC\User\User')
+ $user2 = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user2->expects($this->never())
->method('setEnabled');
@@ -2829,7 +2831,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('abc')
->willReturn($user2);
- $subadmin = $this->createMock('\OC\SubAdmin');
+ $subadmin = $this->createMock(SubAdmin::class);
$subadmin->expects($this->once())
->method('isUserAccessible')
->will($this->returnValue(false));
@@ -2852,7 +2854,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testEnableUserFailsDueNoUser() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2885,7 +2887,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testEnableUserFailsDueNoUserForSubAdmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2918,7 +2920,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testEnableUserSuccessForAdmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2927,7 +2929,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(1))
->method('getUser')
->will($this->returnValue($user));
- $user2 = $this->getMockBuilder('\OC\User\User')
+ $user2 = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user2->expects($this->once())
->method('setEnabled');
@@ -2955,7 +2957,7 @@ class UsersControllerTest extends \Test\TestCase {
}
public function testEnableUserSuccessForSubAdmin() {
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user->expects($this->once())
->method('getUID')
@@ -2964,7 +2966,7 @@ class UsersControllerTest extends \Test\TestCase {
->expects($this->exactly(2))
->method('getUser')
->will($this->returnValue($user));
- $user2 = $this->getMockBuilder('\OC\User\User')
+ $user2 = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$user2->expects($this->once())
->method('setEnabled')
@@ -2975,7 +2977,7 @@ class UsersControllerTest extends \Test\TestCase {
->with('abc')
->willReturn($user2);
- $subadmin = $this->createMock('\OC\SubAdmin');
+ $subadmin = $this->createMock(SubAdmin::class);
$subadmin->expects($this->once())
->method('isUserAccessible')
->will($this->returnValue(true));
diff --git a/tests/Settings/Middleware/SubadminMiddlewareTest.php b/tests/Settings/Middleware/SubadminMiddlewareTest.php
index b2724047750..834a3fedf23 100644
--- a/tests/Settings/Middleware/SubadminMiddlewareTest.php
+++ b/tests/Settings/Middleware/SubadminMiddlewareTest.php
@@ -34,9 +34,9 @@ class SubadminMiddlewareTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->reflector = $this->getMockBuilder('\OC\AppFramework\Utility\ControllerMethodReflector')
+ $this->reflector = $this->getMockBuilder(ControllerMethodReflector::class)
->disableOriginalConstructor()->getMock();
- $this->controller = $this->getMockBuilder('\OCP\AppFramework\Controller')
+ $this->controller = $this->getMockBuilder(Controller::class)
->disableOriginalConstructor()->getMock();
$this->subadminMiddlewareAsSubAdmin = new SubadminMiddleware($this->reflector, true);
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature
index 37e01bcada2..ac2d05fac2c 100644
--- a/tests/acceptance/features/app-files.feature
+++ b/tests/acceptance/features/app-files.feature
@@ -145,6 +145,14 @@ Feature: app-files
Given I am logged in
And I create a new folder named "A name alphabetically lower than welcome.txt"
And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list
+ # To mark the file as favorite the file actions menu has to be shown but, as
+ # the details view is opened automatically when the folder is created,
+ # clicking on the menu trigger could fail if it is covered by the details
+ # view due to its opening animation. Instead of ensuring that the animations
+ # of the contents and the details view have both finished it is easier to
+ # close the details view and wait until it is closed before continuing.
+ And I close the details view
+ And I see that the details view is closed
When I mark "welcome.txt" as favorite
Then I see that "welcome.txt" is marked as favorite
And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list
@@ -153,6 +161,14 @@ Feature: app-files
Given I am logged in
And I create a new folder named "A name alphabetically lower than welcome.txt"
And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list
+ # To mark the file as favorite the file actions menu has to be shown but, as
+ # the details view is opened automatically when the folder is created,
+ # clicking on the menu trigger could fail if it is covered by the details
+ # view due to its opening animation. Instead of ensuring that the animations
+ # of the contents and the details view have both finished it is easier to
+ # close the details view and wait until it is closed before continuing.
+ And I close the details view
+ And I see that the details view is closed
And I mark "welcome.txt" as favorite
And I see that "welcome.txt" is marked as favorite
And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index bb088c0a2c3..338823a9478 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -80,6 +80,15 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function closeDetailsViewButton() {
+ return Locator::forThe()->css(".icon-close")->
+ descendantOf(self::currentSectionDetailsView())->
+ describedAs("Close current section details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetailsText) {
return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
descendantOf(self::fileDetailsInCurrentSectionDetailsView())->
@@ -278,16 +287,16 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
- public static function favoriteActionForFile($fileName) {
- return Locator::forThe()->css(".action-favorite")->descendantOf(self::rowForFile($fileName))->
- describedAs("Favorite action for file $fileName in Files app");
+ public static function favoriteMarkForFile($fileName) {
+ return Locator::forThe()->css(".favorite-mark")->descendantOf(self::rowForFile($fileName))->
+ describedAs("Favorite mark for file $fileName in Files app");
}
/**
* @return Locator
*/
public static function notFavoritedStateIconForFile($fileName) {
- return Locator::forThe()->css(".icon-star")->descendantOf(self::favoriteActionForFile($fileName))->
+ return Locator::forThe()->css(".icon-star")->descendantOf(self::favoriteMarkForFile($fileName))->
describedAs("Not favorited state icon for file $fileName in Files app");
}
@@ -295,7 +304,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function favoritedStateIconForFile($fileName) {
- return Locator::forThe()->css(".icon-starred")->descendantOf(self::favoriteActionForFile($fileName))->
+ return Locator::forThe()->css(".icon-starred")->descendantOf(self::favoriteMarkForFile($fileName))->
describedAs("Favorited state icon for file $fileName in Files app");
}
@@ -341,6 +350,20 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function addToFavoritesMenuItem() {
+ return self::fileActionsMenuItemFor("Add to favorites");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function removeFromFavoritesMenuItem() {
+ return self::fileActionsMenuItemFor("Remove from favorites");
+ }
+
+ /**
+ * @return Locator
+ */
public static function viewFileInFolderMenuItem() {
return self::fileActionsMenuItemFor("View in folder");
}
@@ -374,6 +397,13 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Given I close the details view
+ */
+ public function iCloseTheDetailsView() {
+ $this->actor->find(self::closeDetailsViewButton(), 10)->click();
+ }
+
+ /**
* @Given I open the input field for tags in the details view
*/
public function iOpenTheInputFieldForTagsInTheDetailsView() {
@@ -393,7 +423,9 @@ class FilesAppContext implements Context, ActorAwareInterface {
public function iMarkAsFavorite($fileName) {
$this->iSeeThatIsNotMarkedAsFavorite($fileName);
- $this->actor->find(self::favoriteActionForFile($fileName), 10)->click();
+ $this->actor->find(self::fileActionsMenuButtonForFile($fileName), 10)->click();
+
+ $this->actor->find(self::addToFavoritesMenuItem(), 2)->click();
}
/**
@@ -402,7 +434,9 @@ class FilesAppContext implements Context, ActorAwareInterface {
public function iUnmarkAsFavorite($fileName) {
$this->iSeeThatIsMarkedAsFavorite($fileName);
- $this->actor->find(self::favoriteActionForFile($fileName), 10)->click();
+ $this->actor->find(self::fileActionsMenuButtonForFile($fileName), 10)->click();
+
+ $this->actor->find(self::removeFromFavoritesMenuItem(), 2)->click();
}
/**
diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh
index 1b68f8655ae..89fdda02630 100755
--- a/tests/acceptance/run.sh
+++ b/tests/acceptance/run.sh
@@ -138,7 +138,7 @@ function prepareDocker() {
# Selenium server.
# The container exits immediately if no command is given, so a Bash session
# is created to prevent that.
- docker run --detach --name=$NEXTCLOUD_LOCAL_CONTAINER --network=container:$SELENIUM_CONTAINER --interactive --tty nextcloudci/php7.0:php7.0-7 bash
+ docker run --detach --name=$NEXTCLOUD_LOCAL_CONTAINER --network=container:$SELENIUM_CONTAINER --interactive --tty nextcloudci/php7.1:php7.1-15 bash
# Use the $TMPDIR or, if not set, fall back to /tmp.
NEXTCLOUD_LOCAL_TAR="$($MKTEMP --tmpdir="${TMPDIR:-/tmp}" --suffix=.tar nextcloud-local-XXXXXXXXXX)"
diff --git a/tests/lib/APITest.php b/tests/lib/APITest.php
index c2a25d1306c..b1ac8fbb24f 100644
--- a/tests/lib/APITest.php
+++ b/tests/lib/APITest.php
@@ -8,6 +8,8 @@
namespace Test;
+use OCP\IRequest;
+
class APITest extends \Test\TestCase {
// Helps build a response variable
@@ -71,7 +73,7 @@ class APITest extends \Test\TestCase {
* @param bool $expected
*/
public function testIsV2($scriptName, $expected) {
- $request = $this->getMockBuilder('\OCP\IRequest')
+ $request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
$request
diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php
index 6cefebdea86..c4add0244bd 100644
--- a/tests/lib/Accounts/AccountsManagerTest.php
+++ b/tests/lib/Accounts/AccountsManagerTest.php
@@ -71,7 +71,7 @@ class AccountsManagerTest extends TestCase {
* @return \PHPUnit_Framework_MockObject_MockObject | AccountManager
*/
public function getInstance($mockedMethods = null) {
- return $this->getMockBuilder('OC\Accounts\AccountManager')
+ return $this->getMockBuilder(AccountManager::class)
->setConstructorArgs([$this->connection, $this->eventDispatcher, $this->jobList])
->setMethods($mockedMethods)
->getMock();
@@ -146,7 +146,7 @@ class AccountsManagerTest extends TestCase {
* @param array $setData
* @param IUser $askUser
* @param array $expectedData
- * @param book $userAlreadyExists
+ * @param bool $userAlreadyExists
*/
public function testGetUser($setUser, $setData, $askUser, $expectedData, $userAlreadyExists) {
$accountManager = $this->getInstance(['buildDefaultUserRecord', 'insertNewUser', 'addMissingDefaultValues']);
@@ -172,9 +172,9 @@ class AccountsManagerTest extends TestCase {
}
public function dataTestGetUser() {
- $user1 = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user1 = $this->getMockBuilder(IUser::class)->getMock();
$user1->expects($this->any())->method('getUID')->willReturn('user1');
- $user2 = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user2 = $this->getMockBuilder(IUser::class)->getMock();
$user2->expects($this->any())->method('getUID')->willReturn('user2');
return [
['user1', ['key' => 'value'], $user1, ['key' => 'value'], true],
@@ -183,7 +183,7 @@ class AccountsManagerTest extends TestCase {
}
public function testUpdateExistingUser() {
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->once())->method('getUID')->willReturn('uid');
$oldData = ['key' => 'value'];
$newData = ['newKey' => 'newValue'];
@@ -196,7 +196,7 @@ class AccountsManagerTest extends TestCase {
}
public function testInsertNewUser() {
- $user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$uid = 'uid';
$data = ['key' => 'value'];
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php
index 13932f389f8..a1877d3fcc6 100644
--- a/tests/lib/Activity/ManagerTest.php
+++ b/tests/lib/Activity/ManagerTest.php
@@ -12,6 +12,7 @@ namespace Test\Activity;
use OCP\IConfig;
use OCP\IRequest;
+use OCP\IUser;
use OCP\IUserSession;
use OCP\RichObjectStrings\IValidator;
use Test\TestCase;
@@ -247,7 +248,7 @@ class ManagerTest extends TestCase {
}
protected function mockUserSession($user) {
- $mockUser = $this->getMockBuilder('\OCP\IUser')
+ $mockUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
$mockUser->expects($this->any())
@@ -314,7 +315,7 @@ class ManagerTest extends TestCase {
*/
public function testPublish($author, $expected) {
if ($author !== null) {
- $authorObject = $this->getMockBuilder('OCP\IUser')
+ $authorObject = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
$authorObject->expects($this->once())
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index 65b45a002d4..081f6d767db 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -59,7 +59,7 @@ class DependencyAnalyzerTest extends TestCase {
->method('getOcVersion')
->will( $this->returnValue('8.0.2'));
- $this->l10nMock = $this->getMockBuilder('\OCP\IL10N')
+ $this->l10nMock = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()
->getMock();
$this->l10nMock->expects($this->any())
diff --git a/tests/lib/AppFramework/Controller/ApiControllerTest.php b/tests/lib/AppFramework/Controller/ApiControllerTest.php
index 74231b8d6ac..b7172ab6a9f 100644
--- a/tests/lib/AppFramework/Controller/ApiControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ApiControllerTest.php
@@ -26,6 +26,7 @@ namespace Test\AppFramework\Controller;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\ApiController;
+use OCP\IConfig;
class ChildApiController extends ApiController {};
@@ -41,7 +42,7 @@ class ApiControllerTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php
index 5c8124c5e7f..ca71e9154ef 100644
--- a/tests/lib/AppFramework/Controller/ControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ControllerTest.php
@@ -29,6 +29,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\DataResponse;
+use OCP\IConfig;
class ChildController extends Controller {
@@ -79,7 +80,7 @@ class ControllerTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index c2d73adfd7b..eb08d00e358 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -31,6 +31,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;
+use OCP\IConfig;
class TestController extends Controller {
@@ -301,7 +302,7 @@ class DispatcherTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
@@ -332,7 +333,7 @@ class DispatcherTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
@@ -366,7 +367,7 @@ class DispatcherTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
@@ -399,7 +400,7 @@ class DispatcherTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
@@ -433,7 +434,7 @@ class DispatcherTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
@@ -469,7 +470,7 @@ class DispatcherTest extends \Test\TestCase {
$this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()
->getMock(),
- $this->getMockBuilder('\OCP\IConfig')
+ $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock()
);
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index 40698ef8d73..d3f36a6d886 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -40,7 +40,7 @@ class RequestTest extends \Test\TestCase {
stream_wrapper_register('fakeinput', 'Test\AppFramework\Http\RequestStream');
$this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->csrfTokenManager = $this->getMockBuilder('\OC\Security\CSRF\CsrfTokenManager')
->disableOriginalConstructor()->getMock();
}
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index f948e184f53..e71be9c5f16 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -29,6 +29,7 @@ use OC\AppFramework\Middleware\MiddlewareDispatcher;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
+use OCP\IConfig;
// needed to test ordering
@@ -133,7 +134,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
new Request(
['method' => 'GET'],
$this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(),
- $this->getMockBuilder('\OCP\IConfig')->getMock()
+ $this->getMockBuilder(IConfig::class)->getMock()
)
])->getMock();
}
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index c5c812839b2..07028745676 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -27,6 +27,7 @@ namespace Test\AppFramework\Middleware;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
+use OCP\IConfig;
class ChildMiddleware extends Middleware {};
@@ -59,7 +60,7 @@ class MiddlewareTest extends \Test\TestCase {
new Request(
[],
$this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(),
- $this->getMockBuilder('\OCP\IConfig')->getMock()
+ $this->getMockBuilder(IConfig::class)->getMock()
)
])->getMock();
$this->exception = new \Exception();
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 773cb2b196f..6b311c7ae15 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -37,6 +37,7 @@ use OC\Security\CSP\ContentSecurityPolicyManager;
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
use OC\Security\CSRF\CsrfToken;
use OC\Security\CSRF\CsrfTokenManager;
+use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
@@ -79,6 +80,8 @@ class SecurityMiddlewareTest extends \Test\TestCase {
private $csrfTokenManager;
/** @var ContentSecurityPolicyNonceManager|\PHPUnit_Framework_MockObject_MockObject */
private $cspNonceManager;
+ /** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */
+ private $appManager;
protected function setUp() {
parent::setUp();
@@ -93,6 +96,10 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->contentSecurityPolicyManager = $this->createMock(ContentSecurityPolicyManager::class);
$this->csrfTokenManager = $this->createMock(CsrfTokenManager::class);
$this->cspNonceManager = $this->createMock(ContentSecurityPolicyNonceManager::class);
+ $this->appManager = $this->createMock(IAppManager::class);
+ $this->appManager->expects($this->any())
+ ->method('isEnabledForUser')
+ ->willReturn(true);
$this->middleware = $this->getMiddleware(true, true);
$this->secException = new SecurityException('hey', false);
$this->secAjaxException = new SecurityException('hey', true);
@@ -116,7 +123,8 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$isAdminUser,
$this->contentSecurityPolicyManager,
$this->csrfTokenManager,
- $this->cspNonceManager
+ $this->cspNonceManager,
+ $this->appManager
);
}
diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
index 3c218bb53c7..8d097e3a8a1 100644
--- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
@@ -17,6 +17,7 @@ use OC\AppFramework\Middleware\SessionMiddleware;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
+use OCP\IConfig;
class SessionMiddlewareTest extends \Test\TestCase {
@@ -36,7 +37,7 @@ class SessionMiddlewareTest extends \Test\TestCase {
$this->request = new Request(
[],
$this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(),
- $this->getMockBuilder('\OCP\IConfig')->getMock()
+ $this->getMockBuilder(IConfig::class)->getMock()
);
$this->reflector = new ControllerMethodReflector();
$this->controller = $this->createMock(Controller::class);
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php
index d395584d011..76533fff014 100644
--- a/tests/lib/AppFramework/Routing/RoutingTest.php
+++ b/tests/lib/AppFramework/Routing/RoutingTest.php
@@ -5,6 +5,7 @@ namespace Test\AppFramework\Routing;
use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Routing\RouteActionHandler;
use OC\AppFramework\Routing\RouteConfig;
+use OCP\ILogger;
class RoutingTest extends \Test\TestCase
{
@@ -130,7 +131,7 @@ class RoutingTest extends \Test\TestCase
// router mock
$router = $this->getMockBuilder('\OC\Route\Router')
->setMethods(['create'])
- ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()])
+ ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()])
->getMock();
// load route configuration
@@ -151,7 +152,7 @@ class RoutingTest extends \Test\TestCase
// router mock
$router = $this->getMockBuilder('\OC\Route\Router')
->setMethods(['create'])
- ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()])
+ ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()])
->getMock();
// load route configuration
@@ -212,7 +213,7 @@ class RoutingTest extends \Test\TestCase
// router mock
$router = $this->getMockBuilder('\OC\Route\Router')
->setMethods(['create'])
- ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()])
+ ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()])
->getMock();
// we expect create to be called once:
@@ -260,7 +261,7 @@ class RoutingTest extends \Test\TestCase
// router mock
$router = $this->getMockBuilder('\OC\Route\Router')
->setMethods(['create'])
- ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()])
+ ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()])
->getMock();
// we expect create to be called once:
@@ -287,7 +288,7 @@ class RoutingTest extends \Test\TestCase
// router mock
$router = $this->getMockBuilder('\OC\Route\Router')
->setMethods(['create'])
- ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()])
+ ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()])
->getMock();
// route mocks
diff --git a/tests/lib/BackgroundJob/JobTest.php b/tests/lib/BackgroundJob/JobTest.php
index 7923eef11ef..ecd8bde8626 100644
--- a/tests/lib/BackgroundJob/JobTest.php
+++ b/tests/lib/BackgroundJob/JobTest.php
@@ -8,6 +8,8 @@
namespace Test\BackgroundJob;
+use OCP\ILogger;
+
class JobTest extends \Test\TestCase {
private $run = false;
@@ -24,7 +26,7 @@ class JobTest extends \Test\TestCase {
});
$jobList->add($job);
- $logger = $this->getMockBuilder('OCP\ILogger')
+ $logger = $this->getMockBuilder(ILogger::class)
->disableOriginalConstructor()
->getMock();
$logger->expects($this->once())
diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php
index 139940eb306..8df385e6ef9 100644
--- a/tests/lib/CapabilitiesManagerTest.php
+++ b/tests/lib/CapabilitiesManagerTest.php
@@ -37,7 +37,7 @@ class CapabilitiesManagerTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock();
+ $this->logger = $this->getMockBuilder(ILogger::class)->getMock();
$this->manager = new CapabilitiesManager($this->logger);
}
diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
new file mode 100644
index 00000000000..90ea90237a1
--- /dev/null
+++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Joas Schilling
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\Collaboration\Collaborators;
+
+
+use OC\Collaboration\Collaborators\Search;
+use OC\Collaboration\Collaborators\SearchResult;
+use OCP\Collaboration\Collaborators\ISearch;
+use OCP\Collaboration\Collaborators\ISearchPlugin;
+use OCP\Collaboration\Collaborators\SearchResultType;
+use OCP\IContainer;
+use OCP\Share;
+use Test\TestCase;
+
+class SearchResultTest extends TestCase {
+ /** @var IContainer|\PHPUnit_Framework_MockObject_MockObject */
+ protected $container;
+ /** @var ISearch */
+ protected $search;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->container = $this->createMock(IContainer::class);
+
+ $this->search = new Search($this->container);
+ }
+
+ public function dataAddResultSet() {
+ return [
+ [[], ['exact' => []]],
+ [['users' => ['exact' => null, 'loose' => []]], ['exact' => ['users' => []], 'users' => []]],
+ [['groups' => ['exact' => null, 'loose' => ['l1']]], ['exact' => ['groups' => []], 'groups' => ['l1']]],
+ [['users' => ['exact' => ['e1'], 'loose' => []]], ['exact' => ['users' => ['e1']], 'users' => []]],
+ ];
+ }
+
+ /**
+ * @dataProvider dataAddResultSet
+ * @param array $toAdd
+ * @param array $expected
+ */
+ public function testAddResultSet(array $toAdd, array $expected) {
+ $result = new SearchResult();
+
+ foreach ($toAdd as $type => $results) {
+ $result->addResultSet(new SearchResultType($type), $results['loose'], $results['exact']);
+ }
+
+ $this->assertEquals($expected, $result->asArray());
+ }
+
+ public function dataHasResult() {
+ $result = ['value' => ['shareWith' => 'l1']];
+ return [
+ [[],'users', 'n1', false],
+ [['users' => ['exact' => null, 'loose' => [$result]]], 'users', 'l1', true],
+ [['users' => ['exact' => null, 'loose' => [$result]]], 'users', 'l2', false],
+ [['users' => ['exact' => null, 'loose' => [$result]]], 'groups', 'l1', false],
+ [['users' => ['exact' => [$result], 'loose' => []]], 'users', 'l1', true],
+ [['users' => ['exact' => [$result], 'loose' => []]], 'users', 'l2', false],
+ [['users' => ['exact' => [$result], 'loose' => []]], 'groups', 'l1', false],
+
+ ];
+ }
+
+ /**
+ * @dataProvider dataHasResult
+ * @param array $toAdd
+ * @param string $type
+ * @param string $id
+ * @param bool $expected
+ */
+ public function testHasResult(array $toAdd, $type, $id, $expected) {
+ $result = new SearchResult();
+
+ foreach ($toAdd as $addType => $results) {
+ $result->addResultSet(new SearchResultType($addType), $results['loose'], $results['exact']);
+ }
+
+ $this->assertSame($expected, $result->hasResult(new SearchResultType($type), $id));
+ }
+
+}
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index e4f45c4bb86..ea718240c5e 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -41,6 +41,9 @@ class MigratorTest extends \Test\TestCase {
/** @var string */
private $tableName;
+ /** @var string */
+ private $tableNameTmp;
+
protected function setUp() {
parent::setUp();
@@ -50,11 +53,23 @@ class MigratorTest extends \Test\TestCase {
$this->markTestSkipped('DB migration tests are not supported on OCI');
}
$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
- $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
+ $this->tableName = $this->getUniqueTableName();
+ $this->tableNameTmp = $this->getUniqueTableName();
+ }
+
+ private function getUniqueTableName() {
+ return strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
}
protected function tearDown() {
- $this->connection->exec('DROP TABLE ' . $this->tableName);
+ // Try to delete if exists (IF EXISTS NOT SUPPORTED IN ORACLE)
+ try {
+ $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp));
+ } catch (\Doctrine\DBAL\DBALException $e) {}
+
+ try {
+ $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableName));
+ } catch (\Doctrine\DBAL\DBALException $e) {}
parent::tearDown();
}
@@ -200,4 +215,24 @@ class MigratorTest extends \Test\TestCase {
$this->assertTrue(true);
}
+
+ public function testAddingForeignKey() {
+ $startSchema = new Schema([], [], $this->getSchemaConfig());
+ $table = $startSchema->createTable($this->tableName);
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->addColumn('name', 'string');
+ $table->setPrimaryKey(['id']);
+
+ $fkName = "fkc";
+ $tableFk = $startSchema->createTable($this->tableNameTmp);
+ $tableFk->addColumn('fk_id', 'integer');
+ $tableFk->addColumn('name', 'string');
+ $tableFk->addForeignKeyConstraint($this->tableName, array('fk_id'), array('id'), array(), $fkName);
+
+ $migrator = $this->manager->getMigrator();
+ $migrator->migrate($startSchema);
+
+
+ $this->assertTrue($startSchema->getTable($this->tableNameTmp)->hasForeignKey($fkName));
+ }
}
diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php
index 85884c9bfb4..deb6a7c783c 100644
--- a/tests/lib/DateTimeFormatterTest.php
+++ b/tests/lib/DateTimeFormatterTest.php
@@ -46,10 +46,13 @@ class DateTimeFormatterTest extends TestCase {
$deL10N = \OC::$server->getL10N('lib', 'de');
return array(
array('seconds ago', $time, $time),
+ array('in a few seconds', $time + 5 , $time),
array('1 minute ago', $this->getTimestampAgo($time, 30, 1), $time),
array('15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time),
+ array('in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)),
array('1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time),
array('3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time),
+ array('in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)),
array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time),
array('seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')),
@@ -86,9 +89,15 @@ class DateTimeFormatterTest extends TestCase {
// Normal testing
array('today', $this->getTimestampAgo($time, 30, 15), $time),
array('yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time),
+ array('tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)),
array('4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time),
+ array('in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)),
array('5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time),
+ array('next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)),
+ array('in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)),
array('2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time),
+ array('next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)),
+ array('in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)),
// Test with compare timestamp
array('today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)),
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 289e7de27ab..06c5e0e2df8 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -28,8 +28,13 @@ use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Encryption\Manager;
use OC\Files\FileInfo;
use OC\Files\View;
+use OCP\Files\Storage;
use OCP\IUserManager;
+use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+use Symfony\Component\Console\Helper\ProgressBar;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
/**
@@ -65,17 +70,17 @@ class DecryptAllTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->userManager = $this->getMockBuilder('OCP\IUserManager')
+ $this->userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()->getMock();
$this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager')
->disableOriginalConstructor()->getMock();
- $this->view = $this->getMockBuilder('OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
- $this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')
+ $this->inputInterface = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor()->getMock();
- $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')
+ $this->outputInterface = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()->getMock();
- $this->userInterface = $this->getMockBuilder('OCP\UserInterface')
+ $this->userInterface = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock();
$this->outputInterface->expects($this->any())->method('getFormatter')
@@ -252,11 +257,11 @@ class DecryptAllTest extends TestCase {
->setMethods(['decryptFile'])
->getMock();
- $storage = $this->getMockBuilder('OCP\Files\Storage')
+ $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock();
- $sharedStorage = $this->getMockBuilder('OCP\Files\Storage')
+ $sharedStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock();
$sharedStorage->expects($this->once())->method('instanceOfStorage')
@@ -295,7 +300,7 @@ class DecryptAllTest extends TestCase {
->method('decryptFile')
->with('/user1/files/foo/subfile');
- $progressBar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')
+ $progressBar = $this->getMockBuilder(ProgressBar::class)
->disableOriginalConstructor()->getMock();
$this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']);
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 6a6a3db2f68..d20efa8821f 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -26,6 +26,7 @@ namespace Test\Encryption;
use OC\Encryption\EncryptionWrapper;
use OC\Encryption\Manager;
use OC\Memcache\ArrayCache;
+use OCP\Files\Storage;
use OCP\ILogger;
use Test\TestCase;
@@ -59,7 +60,7 @@ class EncryptionWrapperTest extends TestCase {
* @dataProvider provideWrapStorage
*/
public function testWrapStorage($expectedWrapped, $wrappedStorages) {
- $storage = $this->getMockBuilder('OC\Files\Storage\Storage')
+ $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index 4e9719351f3..cd8f1e9b953 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -24,6 +24,8 @@
namespace Test\Encryption\Keys;
use OC\Encryption\Keys\Storage;
+use OC\Files\View;
+use OCP\IConfig;
use Test\TestCase;
class StorageTest extends TestCase {
@@ -47,11 +49,11 @@ class StorageTest extends TestCase {
->disableOriginalConstructor()
->getMock();
- $this->view = $this->getMockBuilder('OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
- $this->config = $this->getMockBuilder('OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php
index b222bc42d7a..a8cbef70d75 100644
--- a/tests/lib/Encryption/UpdateTest.php
+++ b/tests/lib/Encryption/UpdateTest.php
@@ -24,6 +24,8 @@ namespace Test\Encryption;
use OC\Encryption\Update;
+use OC\Files\Mount\Manager;
+use OC\Files\View;
use Test\TestCase;
class UpdateTest extends TestCase {
@@ -55,11 +57,11 @@ class UpdateTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->view = $this->getMockBuilder('\OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$this->util = $this->getMockBuilder('\OC\Encryption\Util')
->disableOriginalConstructor()->getMock();
- $this->mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ $this->mountManager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()->getMock();
$this->encryptionManager = $this->getMockBuilder('\OC\Encryption\Manager')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index 609f6ae1e68..1e1b21d3671 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -3,7 +3,9 @@
namespace Test\Encryption;
use OC\Encryption\Util;
+use OC\Files\View;
use OCP\Encryption\IEncryptionModule;
+use OCP\IConfig;
use Test\TestCase;
class UtilTest extends TestCase {
@@ -32,7 +34,7 @@ class UtilTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->view = $this->getMockBuilder('OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
@@ -44,7 +46,7 @@ class UtilTest extends TestCase {
->disableOriginalConstructor()
->getMock();
- $this->config = $this->getMockBuilder('OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/FileChunkingTest.php b/tests/lib/FileChunkingTest.php
index cf0fed251a4..42fc820c5d0 100644
--- a/tests/lib/FileChunkingTest.php
+++ b/tests/lib/FileChunkingTest.php
@@ -47,7 +47,7 @@ class FileChunkingTest extends \Test\TestCase {
* @param $expected
*/
public function testIsComplete($total, array $present, $expected) {
- $fileChunking = $this->getMockBuilder('\OC_FileChunking')
+ $fileChunking = $this->getMockBuilder(\OC_FileChunking::class)
->setMethods(['getCache'])
->setConstructorArgs([[
'name' => 'file',
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index ec043c7b81e..6479dad58d3 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -786,7 +786,7 @@ class FolderTest extends NodeTest {
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
- $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
+ $folderInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock();
$baseTime = 1000;
@@ -847,7 +847,7 @@ class FolderTest extends NodeTest {
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
- $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
+ $folderInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock();
$baseTime = 1000;
@@ -906,7 +906,7 @@ class FolderTest extends NodeTest {
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
- $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
+ $folderInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock();
$baseTime = 1000;
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php
index 5e18caa2014..9200ae69f75 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -9,11 +9,15 @@
namespace Test\Files\Node;
use OC\Files\FileInfo;
+use OC\Files\Mount\Manager;
use OC\Files\View;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
+use OCP\Files\Storage;
+use OCP\IConfig;
use OCP\ILogger;
+use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Files\NotFoundException;
@@ -41,17 +45,18 @@ abstract class NodeTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $config = $this->getMockBuilder('\OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator
+ ::class)
->disableOriginalConstructor()
->getMock();
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlGenerator);
- $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ $this->manager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
- $this->view = $this->getMockBuilder('\OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
$this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
@@ -88,7 +93,7 @@ abstract class NodeTest extends \Test\TestCase {
protected abstract function getViewDeleteMethod();
protected function getMockStorage() {
- $storage = $this->getMockBuilder('\OCP\Files\Storage')
+ $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
$storage->expects($this->any())
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index fbc33cafcd8..fd050c8d90c 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -13,7 +13,9 @@ use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Node\Folder;
use OC\Files\View;
+use OCP\IConfig;
use OCP\ILogger;
+use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
@@ -37,15 +39,15 @@ class RootTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $config = $this->getMockBuilder('\OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
- $urlgenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlgenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlgenerator);
- $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ $this->manager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
$this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
@@ -69,7 +71,7 @@ class RootTest extends \Test\TestCase {
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
- $view = $this->getMockBuilder('\OC\Files\View')
+ $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
$root = new \OC\Files\Node\Root(
@@ -105,7 +107,7 @@ class RootTest extends \Test\TestCase {
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
- $view = $this->getMockBuilder('\OC\Files\View')
+ $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
$root = new \OC\Files\Node\Root(
@@ -133,7 +135,7 @@ class RootTest extends \Test\TestCase {
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
- $view = $this->getMockBuilder('\OC\Files\View')
+ $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
$root = new \OC\Files\Node\Root(
@@ -155,7 +157,7 @@ class RootTest extends \Test\TestCase {
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
- $view = $this->getMockBuilder('\OC\Files\View')
+ $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
$root = new \OC\Files\Node\Root(
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index 80d62b16578..c184752ff7e 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -16,6 +16,7 @@ use OCP\Encryption\IFile;
use OCP\Encryption\Keys\IStorage;
use OCP\Files\Cache\ICache;
use OCP\Files\Mount\IMountPoint;
+use OCP\IConfig;
use OCP\ILogger;
use Test\Files\Storage\Storage;
@@ -120,7 +121,7 @@ class EncryptionTest extends Storage {
->willReturn($mockModule);
$this->arrayCache = $this->createMock(ArrayCache::class);
- $this->config = $this->getMockBuilder('\OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->groupManager = $this->getMockBuilder('\OC\Group\Manager')
@@ -718,7 +719,7 @@ class EncryptionTest extends Storage {
}
public function testCopyBetweenStorageMinimumEncryptedVersion() {
- $storage2 = $this->getMockBuilder('OCP\Files\Storage')
+ $storage2 = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
@@ -767,7 +768,7 @@ class EncryptionTest extends Storage {
* @param bool $expectedEncrypted
*/
public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) {
- $storage2 = $this->getMockBuilder('OCP\Files\Storage')
+ $storage2 = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
@@ -829,11 +830,11 @@ class EncryptionTest extends Storage {
*/
public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) {
- $sourceStorage = $this->getMockBuilder('OCP\Files\Storage')
+ $sourceStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
- $targetStorage = $this->getMockBuilder('OCP\Files\Storage')
+ $targetStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
index ee01d0c3f26..b796e767a7b 100644
--- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php
+++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
@@ -185,7 +185,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
}
public function testSpaceRoot() {
- $storage = $this->getMockBuilder('\OC\Files\Storage\Local')->disableOriginalConstructor()->getMock();
+ $storage = $this->getMockBuilder(Local::class)->disableOriginalConstructor()->getMock();
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')->disableOriginalConstructor()->getMock();
$storage->expects($this->once())
->method('getCache')
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php
index 1dc9dca0aad..983428ee51d 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -4,6 +4,7 @@ namespace Test\Files\Stream;
use OC\Files\View;
use OC\Memcache\ArrayCache;
+use OCP\IConfig;
class EncryptionTest extends \Test\TestCase {
@@ -29,7 +30,7 @@ class EncryptionTest extends \Test\TestCase {
->disableOriginalConstructor()->getMock();
$encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
->disableOriginalConstructor()->getMock();
- $config = $this->getMockBuilder('\OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$arrayCache = $this->createMock(ArrayCache::class);
diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php
index 5c1f48a806e..1d01a96fcc0 100644
--- a/tests/lib/Files/Type/DetectionTest.php
+++ b/tests/lib/Files/Type/DetectionTest.php
@@ -21,7 +21,8 @@
namespace Test\Files\Type;
-use \OC\Files\Type\Detection;
+use OC\Files\Type\Detection;
+use OCP\IURLGenerator;
class DetectionTest extends \Test\TestCase {
/** @var Detection */
@@ -83,6 +84,8 @@ class DetectionTest extends \Test\TestCase {
$this->assertEquals('application/octet-stream', $this->detection->detectPath('..hidden'));
$this->assertEquals('application/octet-stream', $this->detection->detectPath('foo'));
$this->assertEquals('application/octet-stream', $this->detection->detectPath(''));
+ $this->assertEquals('image/png', $this->detection->detectPath('foo.png.ocTransferId123456789.part'));
+ $this->assertEquals('image/png', $this->detection->detectPath('foo.png.v1234567890'));
}
public function testDetectString() {
@@ -107,7 +110,7 @@ class DetectionTest extends \Test\TestCase {
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -126,7 +129,7 @@ class DetectionTest extends \Test\TestCase {
* Test dir-shareed mimetype
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -146,7 +149,7 @@ class DetectionTest extends \Test\TestCase {
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -166,7 +169,7 @@ class DetectionTest extends \Test\TestCase {
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -186,7 +189,7 @@ class DetectionTest extends \Test\TestCase {
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -216,7 +219,7 @@ class DetectionTest extends \Test\TestCase {
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -246,7 +249,7 @@ class DetectionTest extends \Test\TestCase {
*/
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
@@ -272,7 +275,7 @@ class DetectionTest extends \Test\TestCase {
$mimetypealiases_dist->setContent(json_encode(['foo' => 'foobar/baz'], JSON_FORCE_OBJECT));
//Mock UrlGenerator
- $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlGenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index cab8bd62739..33d5cc0a8a6 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -2350,7 +2350,7 @@ class ViewTest extends \Test\TestCase {
return;
}
- $eventHandler = $this->getMockBuilder('\stdclass')
+ $eventHandler = $this->getMockBuilder(\stdclass::class)
->setMethods(['preCallback', 'postCallback'])
->getMock();
@@ -2425,7 +2425,7 @@ class ViewTest extends \Test\TestCase {
Filesystem::getMountManager()->addMount($mount);
// Listen for events
- $eventHandler = $this->getMockBuilder('\stdclass')
+ $eventHandler = $this->getMockBuilder(\stdclass::class)
->setMethods(['umount', 'post_umount'])
->getMock();
$eventHandler->expects($this->once())
diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php
index c1824566733..c7cbbc2321b 100644
--- a/tests/lib/Group/GroupTest.php
+++ b/tests/lib/Group/GroupTest.php
@@ -10,6 +10,8 @@
namespace Test\Group;
use OC\User\User;
+use OCP\IConfig;
+use OCP\IURLGenerator;
class GroupTest extends \Test\TestCase {
@@ -19,10 +21,10 @@ class GroupTest extends \Test\TestCase {
* @return User
*/
private function newUser($uid, \OC\User\Backend $backend) {
- $config = $this->getMockBuilder('\OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
- $urlgenerator = $this->getMockBuilder('\OCP\IURLGenerator')
+ $urlgenerator = $this->getMockBuilder(IURLGenerator::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/HTTPHelperTest.php b/tests/lib/HTTPHelperTest.php
index d241acb2f93..d39cc34c464 100644
--- a/tests/lib/HTTPHelperTest.php
+++ b/tests/lib/HTTPHelperTest.php
@@ -9,6 +9,7 @@
namespace Test;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
class HTTPHelperTest extends \Test\TestCase {
@@ -22,7 +23,7 @@ class HTTPHelperTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock();
$this->clientService = $this->createMock(IClientService::class);
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php
index da9cedc9f56..3a30bbd1d3b 100644
--- a/tests/lib/LoggerTest.php
+++ b/tests/lib/LoggerTest.php
@@ -138,6 +138,32 @@ class LoggerTest extends TestCase {
}
}
+ /**
+ * @dataProvider userAndPasswordData
+ */
+ public function testDetectclosure($user, $password) {
+ $a = function($user, $password) {
+ throw new \Exception('test');
+ };
+
+ try {
+ $a($user, $password);
+ } catch (\Exception $e) {
+ $this->logger->logException($e);
+ }
+ $logLines = $this->getLogs();
+
+ foreach($logLines as $logLine) {
+ $log = explode('\n', $logLine);
+ unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0
+ $logLine = implode('\n', $log);
+
+ $this->assertNotContains($user, $logLine);
+ $this->assertNotContains($password, $logLine);
+ $this->assertContains('{closure}(*** sensitive parameters replaced ***)', $logLine);
+ }
+ }
+
public function dataGetLogClass() {
return [
['file', \OC\Log\File::class],
diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php
index 8607ea7de9b..ce6c25cd87f 100644
--- a/tests/lib/Memcache/FactoryTest.php
+++ b/tests/lib/Memcache/FactoryTest.php
@@ -20,6 +20,8 @@
*/
namespace Test\Memcache;
+use OCP\ILogger;
+
class Test_Factory_Available_Cache1 {
public function __construct($prefix = '') {
}
@@ -114,7 +116,7 @@ class FactoryTest extends \Test\TestCase {
*/
public function testCacheAvailability($localCache, $distributedCache, $lockingCache,
$expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) {
- $logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
+ $logger = $this->getMockBuilder(ILogger::class)->getMock();
$factory = new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache, $lockingCache);
$this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache));
$this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache));
@@ -126,7 +128,7 @@ class FactoryTest extends \Test\TestCase {
* @expectedException \OC\HintException
*/
public function testCacheNotAvailableException($localCache, $distributedCache) {
- $logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
+ $logger = $this->getMockBuilder(ILogger::class)->getMock();
new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache);
}
}
diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php
index 2de55f647e7..7a3a960074f 100644
--- a/tests/lib/Migration/BackgroundRepairTest.php
+++ b/tests/lib/Migration/BackgroundRepairTest.php
@@ -72,7 +72,7 @@ class BackgroundRepairTest extends TestCase {
$this->jobList = $this->getMockBuilder('OC\BackgroundJob\JobList')
->disableOriginalConstructor()
->getMock();
- $this->logger = $this->getMockBuilder('OCP\ILogger')
+ $this->logger = $this->getMockBuilder(ILogger::class)
->disableOriginalConstructor()
->getMock();
$this->job = $this->getMockBuilder(BackgroundRepair::class)
diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php
index e280838424b..cb6504b67e7 100644
--- a/tests/lib/Notification/ManagerTest.php
+++ b/tests/lib/Notification/ManagerTest.php
@@ -22,7 +22,10 @@
namespace Test\Notification;
use OC\Notification\Manager;
+use OCP\Notification\IApp;
use OCP\Notification\IManager;
+use OCP\Notification\INotification;
+use OCP\Notification\INotifier;
use OCP\RichObjectStrings\IValidator;
use Test\TestCase;
@@ -37,7 +40,7 @@ class ManagerTest extends TestCase {
}
public function testRegisterApp() {
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
@@ -61,7 +64,7 @@ class ManagerTest extends TestCase {
* @expectedException \InvalidArgumentException
*/
public function testRegisterAppInvalid() {
- $notifier = $this->getMockBuilder('OCP\Notification\INotifier')
+ $notifier = $this->getMockBuilder(INotifier::class)
->disableOriginalConstructor()
->getMock();
@@ -75,7 +78,7 @@ class ManagerTest extends TestCase {
}
public function testRegisterNotifier() {
- $notifier = $this->getMockBuilder('OCP\Notification\INotifier')
+ $notifier = $this->getMockBuilder(INotifier::class)
->disableOriginalConstructor()
->getMock();
@@ -107,7 +110,7 @@ class ManagerTest extends TestCase {
* @expectedException \InvalidArgumentException
*/
public function testRegisterNotifierInvalid() {
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
@@ -138,7 +141,7 @@ class ManagerTest extends TestCase {
* @param mixed $data
*/
public function testRegisterNotifierInfoInvalid($data) {
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
@@ -158,7 +161,7 @@ class ManagerTest extends TestCase {
* @expectedExceptionMessage The given notifier ID test1 is already in use
*/
public function testRegisterNotifierInfoDuplicate() {
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
@@ -184,7 +187,7 @@ class ManagerTest extends TestCase {
public function testNotify() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification->expects($this->once())
@@ -192,7 +195,7 @@ class ManagerTest extends TestCase {
->willReturn(true);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
$app->expects($this->once())
@@ -200,7 +203,7 @@ class ManagerTest extends TestCase {
->with($notification);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */
- $app2 = $this->getMockBuilder('OCP\Notification\IApp')
+ $app2 = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
$app2->expects($this->once())
@@ -222,7 +225,7 @@ class ManagerTest extends TestCase {
*/
public function testNotifyInvalid() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification->expects($this->once())
@@ -234,14 +237,14 @@ class ManagerTest extends TestCase {
public function testPrepare() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification->expects($this->once())
->method('isValidParsed')
->willReturn(true);
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification2 */
- $notification2 = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification2 = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification2->expects($this->exactly(2))
@@ -249,7 +252,7 @@ class ManagerTest extends TestCase {
->willReturn(true);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */
- $notifier = $this->getMockBuilder('OCP\Notification\INotifier')
+ $notifier = $this->getMockBuilder(INotifier::class)
->disableOriginalConstructor()
->getMock();
$notifier->expects($this->once())
@@ -258,7 +261,7 @@ class ManagerTest extends TestCase {
->willReturnArgument(0);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier2 */
- $notifier2 = $this->getMockBuilder('OCP\Notification\INotifier')
+ $notifier2 = $this->getMockBuilder(INotifier::class)
->disableOriginalConstructor()
->getMock();
$notifier2->expects($this->once())
@@ -285,7 +288,7 @@ class ManagerTest extends TestCase {
*/
public function testPrepareInvalid() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification->expects($this->once())
@@ -293,7 +296,7 @@ class ManagerTest extends TestCase {
->willReturn(false);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */
- $notifier = $this->getMockBuilder('OCP\Notification\INotifier')
+ $notifier = $this->getMockBuilder(INotifier::class)
->disableOriginalConstructor()
->getMock();
$notifier->expects($this->once())
@@ -312,7 +315,7 @@ class ManagerTest extends TestCase {
public function testPrepareNotifierThrows() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification->expects($this->once())
@@ -320,7 +323,7 @@ class ManagerTest extends TestCase {
->willReturn(true);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */
- $notifier = $this->getMockBuilder('OCP\Notification\INotifier')
+ $notifier = $this->getMockBuilder(INotifier::class)
->disableOriginalConstructor()
->getMock();
$notifier->expects($this->once())
@@ -342,7 +345,7 @@ class ManagerTest extends TestCase {
*/
public function testPrepareNoNotifier() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
$notification->expects($this->once())
@@ -354,12 +357,12 @@ class ManagerTest extends TestCase {
public function testMarkProcessed() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
$app->expects($this->once())
@@ -367,7 +370,7 @@ class ManagerTest extends TestCase {
->with($notification);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */
- $app2 = $this->getMockBuilder('OCP\Notification\IApp')
+ $app2 = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
$app2->expects($this->once())
@@ -386,12 +389,12 @@ class ManagerTest extends TestCase {
public function testGetCount() {
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
- $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ $notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
->getMock();
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */
- $app = $this->getMockBuilder('OCP\Notification\IApp')
+ $app = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
$app->expects($this->once())
@@ -400,7 +403,7 @@ class ManagerTest extends TestCase {
->willReturn(21);
/** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */
- $app2 = $this->getMockBuilder('OCP\Notification\IApp')
+ $app2 = $this->getMockBuilder(IApp::class)
->disableOriginalConstructor()
->getMock();
$app2->expects($this->once())
diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php
index ac79907c525..115bce49f71 100644
--- a/tests/lib/Repair/CleanTagsTest.php
+++ b/tests/lib/Repair/CleanTagsTest.php
@@ -8,6 +8,7 @@
namespace Test\Repair;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IUserManager;
use OCP\Migration\IOutput;
/**
@@ -41,7 +42,7 @@ class CleanTagsTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
+ $this->userManager = $this->getMockBuilder(IUserManager::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php
index fa75f58472a..0c67cc992ef 100644
--- a/tests/lib/Repair/RepairInvalidSharesTest.php
+++ b/tests/lib/Repair/RepairInvalidSharesTest.php
@@ -11,6 +11,7 @@ namespace Test\Repair;
use OC\Repair\RepairInvalidShares;
use OC\Share\Constants;
+use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Test\TestCase;
@@ -33,7 +34,7 @@ class RepairInvalidSharesTest extends TestCase {
protected function setUp() {
parent::setUp();
- $config = $this->getMockBuilder('OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$config->expects($this->any())
diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php
index 6f3ed5ce318..b9d73d27d00 100644
--- a/tests/lib/Repair/RepairMimeTypesTest.php
+++ b/tests/lib/Repair/RepairMimeTypesTest.php
@@ -39,7 +39,7 @@ class RepairMimeTypesTest extends \Test\TestCase {
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject $config */
- $config = $this->getMockBuilder('OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$config->expects($this->any())
diff --git a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
index d1e76684507..92a6557f8e3 100644
--- a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
+++ b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
@@ -31,7 +31,7 @@ class SessionStorageTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->session = $this->getMockBuilder('\OCP\ISession')
+ $this->session = $this->getMockBuilder(ISession::class)
->disableOriginalConstructor()->getMock();
$this->sessionStorage = new \OC\Security\CSRF\TokenStorage\SessionStorage($this->session);
}
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index 6bdb647abc5..2804ad99c0f 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -9,6 +9,7 @@
namespace Test\Security;
use OC\Files\Storage\Temporary;
+use OC\Files\View;
use \OC\Security\CertificateManager;
use OCP\IConfig;
use OCP\ILogger;
@@ -152,7 +153,7 @@ class CertificateManagerTest extends \Test\TestCase {
$expected
) {
- $view = $this->getMockBuilder('OC\Files\View')
+ $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php
index 913f4d703e8..5f7613a823d 100644
--- a/tests/lib/Security/HasherTest.php
+++ b/tests/lib/Security/HasherTest.php
@@ -9,6 +9,7 @@
namespace Test\Security;
use OC\Security\Hasher;
+use OCP\IConfig;
/**
* Class HasherTest
@@ -75,13 +76,13 @@ class HasherTest extends \Test\TestCase {
/** @var Hasher */
protected $hasher;
- /** @var \OCP\IConfig */
+ /** @var IConfig */
protected $config;
protected function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock();
$this->hasher = new Hasher($this->config);
diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php
index 1beb7a66717..25586a1bc27 100644
--- a/tests/lib/Security/TrustedDomainHelperTest.php
+++ b/tests/lib/Security/TrustedDomainHelperTest.php
@@ -21,7 +21,7 @@ class TrustedDomainHelperTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->config = $this->getMockBuilder(IConfig::class)->getMock();
}
/**
diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php
index e1fadbf933f..f34148fb50e 100644
--- a/tests/lib/Session/CryptoWrappingTest.php
+++ b/tests/lib/Session/CryptoWrappingTest.php
@@ -22,6 +22,7 @@
namespace Test\Session;
use OC\Session\CryptoSessionData;
+use OCP\ISession;
use Test\TestCase;
class CryptoWrappingTest extends TestCase {
@@ -37,7 +38,7 @@ class CryptoWrappingTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->wrappedSession = $this->getMockBuilder('OCP\ISession')
+ $this->wrappedSession = $this->getMockBuilder(ISession::class)
->disableOriginalConstructor()
->getMock();
$this->crypto = $this->getMockBuilder('OCP\Security\ICrypto')
diff --git a/tests/lib/Settings/Admin/AdditionalTest.php b/tests/lib/Settings/Admin/AdditionalTest.php
index 84c63f3aeb1..4a254da060b 100644
--- a/tests/lib/Settings/Admin/AdditionalTest.php
+++ b/tests/lib/Settings/Admin/AdditionalTest.php
@@ -36,7 +36,7 @@ class AdditionalTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->admin = new Additional(
$this->config
diff --git a/tests/lib/Settings/Admin/EncryptionTest.php b/tests/lib/Settings/Admin/EncryptionTest.php
index a5f483863e6..41196a9bc41 100644
--- a/tests/lib/Settings/Admin/EncryptionTest.php
+++ b/tests/lib/Settings/Admin/EncryptionTest.php
@@ -40,7 +40,7 @@ class EncryptionTest extends TestCase {
public function setUp() {
parent::setUp();
$this->manager = $this->getMockBuilder('\OC\Encryption\Manager')->disableOriginalConstructor()->getMock();
- $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
+ $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
$this->admin = new Encryption(
$this->manager,
diff --git a/tests/lib/Settings/Admin/ServerTest.php b/tests/lib/Settings/Admin/ServerTest.php
index 106390f25a5..b8317540117 100644
--- a/tests/lib/Settings/Admin/ServerTest.php
+++ b/tests/lib/Settings/Admin/ServerTest.php
@@ -49,11 +49,11 @@ class ServerTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->request = $this->createMock(IRequest::class);
$this->dbConnection = $this->getMockBuilder('\OCP\IDBConnection')->getMock();
$this->lockingProvider = $this->getMockBuilder('\OCP\Lock\ILockingProvider')->getMock();
- $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
+ $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
$this->admin = new Server(
$this->dbConnection,
diff --git a/tests/lib/Settings/Admin/SharingTest.php b/tests/lib/Settings/Admin/SharingTest.php
index d9aa14fecea..9498a1466d3 100644
--- a/tests/lib/Settings/Admin/SharingTest.php
+++ b/tests/lib/Settings/Admin/SharingTest.php
@@ -36,7 +36,7 @@ class SharingTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->admin = new Sharing(
$this->config
diff --git a/tests/lib/Settings/Admin/TipsTricksTest.php b/tests/lib/Settings/Admin/TipsTricksTest.php
index cbecd51ed55..2bbadab52cb 100644
--- a/tests/lib/Settings/Admin/TipsTricksTest.php
+++ b/tests/lib/Settings/Admin/TipsTricksTest.php
@@ -36,7 +36,7 @@ class TipsTrickTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->admin = new TipsTricks(
$this->config
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php
index 61fac99ca6c..f81bbaf1643 100644
--- a/tests/lib/SystemTag/SystemTagManagerTest.php
+++ b/tests/lib/SystemTag/SystemTagManagerTest.php
@@ -13,6 +13,7 @@ namespace Test\SystemTag;
use OC\SystemTag\SystemTagManager;
use OC\SystemTag\SystemTagObjectMapper;
use OCP\IDBConnection;
+use OCP\IUser;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -56,7 +57,7 @@ class SystemTagManagerTest extends TestCase {
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')
->getMock();
- $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')->getMock();
+ $this->groupManager = $this->getMockBuilder(IGroupManager::class)->getMock();
$this->tagManager = new SystemTagManager(
$this->connection,
@@ -433,7 +434,7 @@ class SystemTagManagerTest extends TestCase {
* @dataProvider visibilityCheckProvider
*/
public function testVisibilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult) {
- $user = $this->getMockBuilder('\OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('test'));
@@ -480,7 +481,7 @@ class SystemTagManagerTest extends TestCase {
* @dataProvider assignabilityCheckProvider
*/
public function testAssignabilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult, $userGroupIds = [], $tagGroupIds = []) {
- $user = $this->getMockBuilder('\OCP\IUser')->getMock();
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('test'));
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 818b3454c3a..64036084dc2 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -491,7 +491,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
->method('getName')
->willReturn('Nextcloud');
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject $l10n */
- $l10n = $this->getMockBuilder('\OCP\IL10N')
+ $l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()->getMock();
$l10n
->expects($this->any())
diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php
index 6f6c6c1ad0c..ff04aa17681 100644
--- a/tests/lib/Updater/VersionCheckTest.php
+++ b/tests/lib/Updater/VersionCheckTest.php
@@ -23,6 +23,7 @@
namespace Test\Updater;
use OC\Updater\VersionCheck;
+use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\Util;
@@ -34,10 +35,10 @@ class VersionCheckTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder('\OCP\IConfig')
+ $this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
- $clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService')
+ $clientService = $this->getMockBuilder(IClientService::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index 9520cd640fd..0d98a9825de 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -615,7 +615,7 @@ class ManagerTest extends TestCase {
}
public function testDeleteUser() {
- $config = $this->getMockBuilder('OCP\IConfig')
+ $config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$config
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index c4d29b979ae..9cbac8dfc29 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -769,7 +769,7 @@ class SessionTest extends \Test\TestCase {
$session = new Memory('');
$session->set('user_id', 'foo');
- $userSession = $this->getMockBuilder('\OC\User\Session')
+ $userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager])
->setMethods([
'validateSession'
@@ -950,7 +950,7 @@ class SessionTest extends \Test\TestCase {
$token->setUid('fritz0');
$token->setLastCheck(100); // Needs check
$user = $this->createMock(IUser::class);
- $userSession = $this->getMockBuilder('\OC\User\Session')
+ $userSession = $this->getMockBuilder(Session::class)
->setMethods(['logout'])
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager])
->getMock();
@@ -980,7 +980,7 @@ class SessionTest extends \Test\TestCase {
$session = $this->createMock(ISession::class);
$timeFactory = $this->createMock(ITimeFactory::class);
$tokenProvider = $this->createMock(IProvider::class);
- $userSession = $this->getMockBuilder('\OC\User\Session')
+ $userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config, $this->random, $this->lockdownManager])
->setMethods(['logout'])
->getMock();
@@ -1027,7 +1027,7 @@ class SessionTest extends \Test\TestCase {
$session = $this->createMock(ISession::class);
$timeFactory = $this->createMock(ITimeFactory::class);
$tokenProvider = $this->createMock(IProvider::class);
- $userSession = $this->getMockBuilder('\OC\User\Session')
+ $userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config, $this->random, $this->lockdownManager])
->setMethods(['logout'])
->getMock();
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index 089f30a1fef..acb171d92e3 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -276,7 +276,7 @@ class UserTest extends TestCase {
->method('implementsActions')
->will($this->returnValue(false));
- $allConfig = $this->getMockBuilder('\OCP\IConfig')
+ $allConfig = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$allConfig->expects($this->any())
diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php
index 52d18571647..49dc4ddebb1 100644
--- a/tests/lib/UtilTest.php
+++ b/tests/lib/UtilTest.php
@@ -10,6 +10,8 @@ namespace Test;
use OC_Util;
use OCP\App\IAppManager;
+use OCP\IConfig;
+use OCP\IUser;
/**
* Class UtilTest
@@ -259,9 +261,9 @@ class UtilTest extends \Test\TestCase {
* @param bool $expected expected result
*/
function testIsSharingDisabledForUser($groups, $membership, $excludedGroups, $expected) {
- $config = $this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock();
+ $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
$groupManager = $this->getMockBuilder('OCP\IGroupManager')->disableOriginalConstructor()->getMock();
- $user = $this->getMockBuilder('OCP\IUser')->disableOriginalConstructor()->getMock();
+ $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$config
->expects($this->at(0))