summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-01 15:37:29 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-01 15:37:29 +0100
commite2805f02aa51c602c581bd4f09b99dd791a42df4 (patch)
tree4ea194f47aa315874c2aac31c30dbdb14110539b /tests/lib
parent2b4b3b1986e58305c08941f77a693a80cc3d5b85 (diff)
parent52b679a2d6f6b273f46334b15534ab312f974a1a (diff)
downloadnextcloud-server-e2805f02aa51c602c581bd4f09b99dd791a42df4.tar.gz
nextcloud-server-e2805f02aa51c602c581bd4f09b99dd791a42df4.zip
Merge branch 'master' into autocomplete-gui
Diffstat (limited to 'tests/lib')
-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
58 files changed, 377 insertions, 141 deletions
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))