summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Connector/Sabre
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-07-15 09:52:46 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-07-15 09:52:46 +0200
commit2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4 (patch)
treeb43ce551bf0a4ea1bd78de7084d3814f35beb12f /apps/dav/tests/unit/Connector/Sabre
parent813b58ab947222f983fe25d56781f1f43c840538 (diff)
downloadnextcloud-server-2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4.tar.gz
nextcloud-server-2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4.zip
Fix PHPUnit 5.4 warnings in DAV app
* getMock is deprecated
Diffstat (limited to 'apps/dav/tests/unit/Connector/Sabre')
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/AuthTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php16
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php14
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php8
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php12
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php27
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FileTest.php72
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php12
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php60
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/NodeTest.php16
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php44
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php5
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php32
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php8
20 files changed, 251 insertions, 101 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
index 9564298f23a..92798797d6c 100644
--- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
@@ -586,7 +586,9 @@ class AuthTest extends TestCase {
->disableOriginalConstructor()
->getMock();
/** @var IUser */
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->method('getUID')->willReturn('MyTestUser');
$this->userSession
->expects($this->any())
diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
index 3859e4f2790..890d11465a4 100644
--- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
@@ -41,7 +41,9 @@ class BlockLegacyClientPluginTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config);
}
@@ -66,7 +68,9 @@ class BlockLegacyClientPluginTest extends TestCase {
*/
public function testBeforeHandlerException($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$request
->expects($this->once())
->method('getHeader')
@@ -101,7 +105,9 @@ class BlockLegacyClientPluginTest extends TestCase {
*/
public function testBeforeHandlerSuccess($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$request
->expects($this->once())
->method('getHeader')
@@ -119,7 +125,9 @@ class BlockLegacyClientPluginTest extends TestCase {
public function testBeforeHandlerNoUserAgent() {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$request
->expects($this->once())
->method('getHeader')
diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
index 6ade77e34f3..70ef5233598 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
@@ -35,8 +35,12 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->server = $this->getMockBuilder('\Sabre\DAV\Server')
->disableOriginalConstructor()
@@ -114,7 +118,11 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
public function userProvider() {
return [
- [$this->getMock('\OCP\IUser')],
+ [
+ $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ],
[null]
];
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
index f4f5e13fcf8..0fb012d9538 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
@@ -67,7 +67,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$userId = $this->getUniqueID('testcustompropertiesuser');
- $this->user = $this->getMock('\OCP\IUser');
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue($userId));
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index 66f0a803807..7511d6b02f7 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -39,8 +39,12 @@ class DirectoryTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->view = $this->getMock('OC\Files\View', array(), array(), '', false);
- $this->info = $this->getMock('OC\Files\FileInfo', array(), array(), '', false);
+ $this->view = $this->getMockBuilder('OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->info = $this->getMockBuilder('OC\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
}
private function getDir($path = '/') {
diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
index 28e4bd7e836..797f306c7ba 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
@@ -43,7 +43,9 @@ class DummyGetResponsePluginTest extends TestCase {
public function testInitialize() {
/** @var \Sabre\DAV\Server $server */
- $server = $this->getMock('\Sabre\DAV\Server');
+ $server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$server
->expects($this->once())
->method('on')
@@ -55,9 +57,13 @@ class DummyGetResponsePluginTest extends TestCase {
public function testHttpGet() {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
/** @var \Sabre\HTTP\ResponseInterface $response */
- $response = $server = $this->getMock('\Sabre\HTTP\ResponseInterface');
+ $response = $server = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$response
->expects($this->once())
->method('setBody');
diff --git a/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php b/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php
index 44e9e17b695..61f78d13547 100644
--- a/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php
@@ -47,7 +47,9 @@ class ForbiddenTest extends \Test\TestCase {
EOD;
$ex = new Forbidden($message, $retry);
- $server = $this->getMock('Sabre\DAV\Server');
+ $server = $this->getMockBuilder('Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$ex->serialize($server, $error);
// assert
diff --git a/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php b/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php
index 0e1224f596a..25960cc3cb8 100644
--- a/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php
@@ -48,7 +48,9 @@ class InvalidPathTest extends \Test\TestCase {
EOD;
$ex = new InvalidPath($message, $retry);
- $server = $this->getMock('Sabre\DAV\Server');
+ $server = $this->getMockBuilder('Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$ex->serialize($server, $error);
// assert
diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
index 096e4439074..29d2ce469a1 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
@@ -42,7 +42,9 @@ class FakeLockerPluginTest extends TestCase {
public function testInitialize() {
/** @var \Sabre\DAV\Server $server */
- $server = $this->getMock('\Sabre\DAV\Server');
+ $server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$server
->expects($this->at(0))
->method('on')
@@ -82,7 +84,9 @@ class FakeLockerPluginTest extends TestCase {
$propFind = $this->getMockBuilder('\Sabre\DAV\PropFind')
->disableOriginalConstructor()
->getMock();
- $node = $this->getMock('\Sabre\DAV\INode');
+ $node = $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock();
$propFind->expects($this->at(0))
->method('handle')
@@ -137,15 +141,20 @@ class FakeLockerPluginTest extends TestCase {
* @param array $expected
*/
public function testValidateTokens(array $input, array $expected) {
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->fakeLockerPlugin->validateTokens($request, $input);
$this->assertSame($expected, $input);
}
public function testFakeLockProvider() {
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$response = new Response();
- $server = $this->getMock('\Sabre\DAV\Server');
+ $server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->getMock();
$this->fakeLockerPlugin->initialize($server);
$request->expects($this->exactly(2))
@@ -160,8 +169,12 @@ class FakeLockerPluginTest extends TestCase {
}
public function testFakeUnlockProvider() {
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
- $response = $this->getMock('\Sabre\HTTP\ResponseInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $response = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$response->expects($this->once())
->method('setStatus')
diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
index 0f404a6a16c..bb87027bd1d 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
@@ -65,7 +65,9 @@ class FileTest extends \Test\TestCase {
}
private function getMockStorage() {
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->getMockBuilder('\OCP\Files\Storage')
+ ->disableOriginalConstructor()
+ ->getMock();
$storage->expects($this->any())
->method('getId')
->will($this->returnValue('home::someuser'));
@@ -144,13 +146,14 @@ class FileTest extends \Test\TestCase {
*/
public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) {
// setup
- $storage = $this->getMock(
- '\OC\Files\Storage\Local',
- ['fopen'],
- [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]
- );
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Local')
+ ->setMethods(['fopen'])
+ ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
+ ->getMock();
\OC\Files\Filesystem::mount($storage, [], $this->user . '/');
- $view = $this->getMock('\OC\Files\View', array('getRelativePath', 'resolvePath'), array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath', 'resolvePath'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('resolvePath')
->will($this->returnCallback(
@@ -202,13 +205,14 @@ class FileTest extends \Test\TestCase {
*/
public function testChunkedPutFails($thrownException, $expectedException, $checkPreviousClass = false) {
// setup
- $storage = $this->getMock(
- '\OC\Files\Storage\Local',
- ['fopen'],
- [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]
- );
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Local')
+ ->setMethods(['fopen'])
+ ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
+ ->getMock();
\OC\Files\Filesystem::mount($storage, [], $this->user . '/');
- $view = $this->getMock('\OC\Files\View', ['getRelativePath', 'resolvePath'], []);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath', 'resolvePath'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('resolvePath')
->will($this->returnCallback(
@@ -526,8 +530,9 @@ class FileTest extends \Test\TestCase {
*/
public function testSimplePutFailsSizeCheck() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array('rename', 'getRelativePath', 'filesize'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['rename', 'getRelativePath', 'filesize'])
+ ->getMock();
$view->expects($this->any())
->method('rename')
->withAnyParameters()
@@ -643,7 +648,9 @@ class FileTest extends \Test\TestCase {
*/
public function testSimplePutInvalidChars() {
// setup
- $view = $this->getMock('\OC\Files\View', array('getRelativePath'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath'])
+ ->getMock();
$view->expects($this->any())
->method('getRelativePath')
->will($this->returnArgument(0));
@@ -678,7 +685,9 @@ class FileTest extends \Test\TestCase {
*/
public function testSetNameInvalidChars() {
// setup
- $view = $this->getMock('\OC\Files\View', array('getRelativePath'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath'])
+ ->getMock();
$view->expects($this->any())
->method('getRelativePath')
@@ -695,8 +704,9 @@ class FileTest extends \Test\TestCase {
*/
public function testUploadAbort() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array('rename', 'getRelativePath', 'filesize'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['rename', 'getRelativePath', 'filesize'])
+ ->getMock();
$view->expects($this->any())
->method('rename')
->withAnyParameters()
@@ -740,8 +750,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteWhenAllowed() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
$view->expects($this->once())
->method('unlink')
@@ -762,8 +772,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteThrowsWhenDeletionNotAllowed() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => 0
@@ -780,8 +790,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteThrowsWhenDeletionFailed() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
// but fails
$view->expects($this->once())
@@ -803,8 +813,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteThrowsWhenDeletionThrows() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
// but fails
$view->expects($this->once())
@@ -953,7 +963,9 @@ class FileTest extends \Test\TestCase {
* @expectedException \Sabre\DAV\Exception\ServiceUnavailable
*/
public function testGetFopenFails() {
- $view = $this->getMock('\OC\Files\View', ['fopen'], array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['fopen'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('fopen')
->will($this->returnValue(false));
@@ -971,7 +983,9 @@ class FileTest extends \Test\TestCase {
* @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden
*/
public function testGetFopenThrows() {
- $view = $this->getMock('\OC\Files\View', ['fopen'], array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['fopen'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('fopen')
->willThrowException(new ForbiddenException('', true));
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
index 2b3f3e15d1a..9419296bd5b 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
@@ -89,11 +89,15 @@ class FilesPluginTest extends TestCase {
$this->view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->config->expects($this->any())->method('getSystemValue')
->with($this->equalTo('data-fingerprint'), $this->equalTo(''))
->willReturn('my_fingerprint');
- $this->request = $this->getMock('\OCP\IRequest');
+ $this->request = $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->plugin = new FilesPlugin(
$this->tree,
@@ -275,7 +279,9 @@ class FilesPluginTest extends TestCase {
$this->tree,
$this->view,
$this->config,
- $this->getMock('\OCP\IRequest'),
+ $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock(),
true);
$this->plugin->initialize($this->server);
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index baf4259b215..71beccd079c 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -82,11 +82,19 @@ class FilesReportPluginTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
@@ -114,7 +122,11 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$this->server->expects($this->any())
->method('getRequestUri')
@@ -133,7 +145,11 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$this->server->expects($this->any())
->method('getRequestUri')
@@ -337,14 +353,18 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('getSize')
->will($this->returnValue(1024));
- $config = $this->getMock('\OCP\IConfig');
+ $config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->server->addPlugin(
new \OCA\DAV\Connector\Sabre\FilesPlugin(
$this->tree,
$this->view,
$config,
- $this->getMock('\OCP\IRequest')
+ $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock()
)
);
$this->plugin->initialize($this->server);
@@ -494,7 +514,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin')
->will($this->returnValue(true));
- $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -502,7 +524,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible')
->will($this->returnValue(true));
- $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -539,7 +563,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin')
->will($this->returnValue(false));
- $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -547,7 +573,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible')
->will($this->returnValue(true));
- $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -573,7 +601,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin')
->will($this->returnValue(false));
- $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -581,7 +611,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible')
->will($this->returnValue(true));
- $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
diff --git a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
index ca7d09565ce..43e875d25d7 100644
--- a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
@@ -40,7 +40,7 @@ class MaintenancePluginTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->maintenancePlugin = new MaintenancePlugin($this->config);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
index 3c7eb6f72c3..328e99c9fbe 100644
--- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
@@ -66,7 +66,9 @@ class NodeTest extends \Test\TestCase {
$info->expects($this->any())
->method('getType')
->will($this->returnValue($type));
- $view = $this->getMock('\OC\Files\View');
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
$node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->assertEquals($expected, $node->getDavPermissions());
@@ -116,10 +118,14 @@ class NodeTest extends \Test\TestCase {
* @dataProvider sharePermissionsProvider
*/
public function testSharePermissions($type, $user, $permissions, $expected) {
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->getMockBuilder('\OCP\Files\Storage')
+ ->disableOriginalConstructor()
+ ->getMock();
$storage->method('getPermissions')->willReturn($permissions);
- $mountpoint = $this->getMock('\OCP\Files\Mount\IMountPoint');
+ $mountpoint = $this->getMockBuilder('\OCP\Files\Mount\IMountPoint')
+ ->disableOriginalConstructor()
+ ->getMock();
$mountpoint->method('getMountPoint')->willReturn('myPath');
$shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock();
$share = $this->getMockBuilder('OCP\Share\IShare')->disableOriginalConstructor()->getMock();
@@ -142,7 +148,9 @@ class NodeTest extends \Test\TestCase {
$info->method('getType')->willReturn($type);
$info->method('getMountPoint')->willReturn($mountpoint);
- $view = $this->getMock('\OC\Files\View');
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
$node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]);
diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
index 96d4357660e..617a0bd5dfa 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
@@ -74,7 +74,9 @@ class TestDoubleFileView extends \OC\Files\View {
class ObjectTreeTest extends \Test\TestCase {
public function getFileInfoMock() {
- $mock = $this->getMock('\OCP\Files\FileInfo');
+ $mock = $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
$mock
->expects($this->any())
->method('isDeletable')
@@ -147,9 +149,10 @@ class ObjectTreeTest extends \Test\TestCase {
$info = new FileInfo('', null, null, array(), null);
$rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
- $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree',
- array('nodeExists', 'getNodeForPath'),
- array($rootDir, $view));
+ $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree')
+ ->setMethods(['nodeExists', 'getNodeForPath'])
+ ->setConstructorArgs([$rootDir, $view])
+ ->getMock();
$objectTree->expects($this->once())
->method('getNodeForPath')
@@ -180,9 +183,15 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
- $mountManager = $this->getMock('\OC\Files\Mount\Manager');
- $view = $this->getMock('\OC\Files\View');
- $fileInfo = $this->getMock('\OCP\Files\FileInfo');
+ $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileInfo = $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
$fileInfo->expects($this->once())
->method('getType')
->will($this->returnValue($type));
@@ -290,7 +299,9 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]);
- $view = $this->getMock('\OC\Files\View', ['resolvePath']);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['resolvePath'])
+ ->getMock();
$view->expects($this->once())
->method('resolvePath')
->will($this->returnCallback(function($path) use ($storage){
@@ -300,7 +311,8 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
- $mountManager = $this->getMock('\OC\Files\Mount\Manager');
+ $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ ->getMock();
$tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$tree->init($rootNode, $view, $mountManager);
@@ -314,7 +326,9 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]);
- $view = $this->getMock('\OC\Files\View', ['resolvePath']);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['resolvePath'])
+ ->getMock();
$view->expects($this->any())
->method('resolvePath')
->will($this->returnCallback(function ($path) use ($storage) {
@@ -324,7 +338,8 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
- $mountManager = $this->getMock('\OC\Files\Mount\Manager');
+ $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ ->getMock();
$tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$tree->init($rootNode, $view, $mountManager);
@@ -347,9 +362,10 @@ class ObjectTreeTest extends \Test\TestCase {
$info = new FileInfo('', null, null, array(), null);
$rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
- $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree',
- array('nodeExists', 'getNodeForPath'),
- array($rootDir, $view));
+ $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree')
+ ->setMethods(['nodeExists', 'getNodeForPath'])
+ ->setConstructorArgs([$rootDir, $view])
+ ->getMock();
$sourceNode = $this->getMockBuilder('\Sabre\DAV\ICollection')
->disableOriginalConstructor()
diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
index c6a1bc3dd4b..bf827fd3585 100644
--- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
@@ -212,7 +212,10 @@ class QuotaPluginTest extends \Test\TestCase {
private function buildFileViewMock($quota, $checkedPath) {
// mock filesysten
- $view = $this->getMock('\OC\Files\View', array('free_space'), array(), '', false);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['free_space'])
+ ->disableOriginalConstructor()
+ ->getMock();
$view->expects($this->any())
->method('free_space')
->with($this->identicalTo($checkedPath))
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
index a69e21c9e32..efa1f0a7a5c 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
@@ -35,7 +35,9 @@ use Test\Traits\EncryptionTrait;
class PartFileInRootUploadTest extends UploadTest {
protected function setUp() {
$config = \OC::$server->getConfig();
- $mockConfig = $this->getMock('\OCP\IConfig');
+ $mockConfig = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$mockConfig->expects($this->any())
->method('getSystemValue')
->will($this->returnCallback(function ($key, $default) use ($config) {
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
index 292c66c003f..3e3f9e59946 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
@@ -62,7 +62,9 @@ abstract class RequestTest extends TestCase {
\OC::$server->getUserSession(),
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
- $this->getMock('\OCP\IRequest')
+ $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock()
);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
index b2d4384133d..0c6446e2911 100644
--- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
@@ -56,17 +56,25 @@ class SharesPluginTest extends \Test\TestCase {
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
- $this->shareManager = $this->getMock('\OCP\Share\IManager');
- $user = $this->getMock('\OCP\IUser');
+ $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1'));
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
$userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($user));
- $this->userFolder = $this->getMock('\OCP\Files\Folder');
+ $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin(
$this->tree,
@@ -92,7 +100,9 @@ class SharesPluginTest extends \Test\TestCase {
->will($this->returnValue('/subdir'));
// node API nodes
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userFolder->expects($this->once())
->method('get')
@@ -168,15 +178,21 @@ class SharesPluginTest extends \Test\TestCase {
->will($this->returnValue('/subdir'));
// node API nodes
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')
+ ->disableOriginalConstructor()
+ ->getMock();
$node->expects($this->any())
->method('getId')
->will($this->returnValue(123));
- $node1 = $this->getMock('\OCP\Files\File');
+ $node1 = $this->getMockBuilder('\OCP\Files\File')
+ ->disableOriginalConstructor()
+ ->getMock();
$node1->expects($this->any())
->method('getId')
->will($this->returnValue(111));
- $node2 = $this->getMock('\OCP\Files\File');
+ $node2 = $this->getMockBuilder('\OCP\Files\File')
+ ->disableOriginalConstructor()
+ ->getMock();
$node2->expects($this->any())
->method('getId')
->will($this->returnValue(222));
diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
index 96bd39de899..8e6e5149714 100644
--- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
@@ -65,8 +65,12 @@ class TagsPluginTest extends \Test\TestCase {
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
- $this->tagger = $this->getMock('\OCP\ITags');
- $this->tagManager = $this->getMock('\OCP\ITagManager');
+ $this->tagger = $this->getMockBuilder('\OCP\ITags')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->tagManager = $this->getMockBuilder('\OCP\ITagManager')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->tagManager->expects($this->any())
->method('load')
->with('files')