Fix PHPUnit 5.4 warnings in DAV app

* getMock is deprecated
This commit is contained in:
Roeland Jago Douma 2016-07-15 09:52:46 +02:00
parent 813b58ab94
commit 2fcb24166f
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
36 changed files with 471 additions and 178 deletions

View File

@ -63,8 +63,12 @@ class AddressBookImplTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->backend = $this->getMockBuilder('\OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()->getMock();
$this->vCard = $this->getMock('Sabre\VObject\Component\VCard');
$this->urlGenerator = $this->getMock('OCP\IURLGenerator');
$this->vCard = $this->getMockBuilder('Sabre\VObject\Component\VCard')
->disableOriginalConstructor()
->getMock();
$this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
->disableOriginalConstructor()
->getMock();
$this->addressBookImpl = new AddressBookImpl(
$this->addressBook,

View File

@ -105,8 +105,10 @@ class BirthdayServiceTest extends TestCase {
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
$service = $this->getMock('\OCA\DAV\CalDAV\BirthdayService',
['buildBirthdayFromContact', 'birthdayEvenChanged'], [$this->calDav, $this->cardDav, $this->groupPrincialBackend]);
$service = $this->getMockBuilder('\OCA\DAV\CalDAV\BirthdayService')
->setMethods(['buildBirthdayFromContact', 'birthdayEvenChanged'])
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincialBackend])
->getMock();
if ($expectedOp === 'delete') {
$this->calDav->expects($this->once())->method('getCalendarObject')->willReturn('');

View File

@ -57,7 +57,10 @@ class ImageExportPluginTest extends TestCase {
$this->server->tree = $this->tree;
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
$this->plugin = $this->getMock('OCA\DAV\CardDAV\ImageExportPlugin', ['getPhoto'], [$this->logger]);
$this->plugin = $this->getMockBuilder('OCA\DAV\CardDAV\ImageExportPlugin')
->setMethods(['getPhoto'])
->setConstructorArgs([$this->logger])
->getMock();
$this->plugin->initialize($this->server);
}

View File

@ -132,7 +132,10 @@ class SyncServiceTest extends TestCase {
$userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock();
/** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $ss */
$ss = $this->getMock('OCA\DAV\CardDAV\SyncService', ['ensureSystemAddressBookExists', 'requestSyncReport', 'download'], [$backend, $userManager, $logger]);
$ss = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
->setMethods(['ensureSystemAddressBookExists', 'requestSyncReport', 'download'])
->setConstructorArgs([$backend, $userManager, $logger])
->getMock();
$ss->method('requestSyncReport')->withAnyParameters()->willReturn(['response' => $response, 'token' => 'sync-token-1']);
$ss->method('ensureSystemAddressBookExists')->willReturn(['id' => 1]);
$ss->method('download')->willReturn([

View File

@ -38,11 +38,21 @@ class CommentsNodeTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->comment = $this->getMock('\OCP\Comments\IComment');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->logger = $this->getMock('\OCP\ILogger');
$this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
->disableOriginalConstructor()
->getMock();
$this->comment = $this->getMockBuilder('\OCP\Comments\IComment')
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')
->disableOriginalConstructor()
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder('\OCP\ILogger')
->disableOriginalConstructor()
->getMock();
$this->node = new CommentNode(
$this->commentsManager,
@ -54,7 +64,9 @@ class CommentsNodeTest extends \Test\TestCase {
}
public function testDelete() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
@ -87,7 +99,9 @@ class CommentsNodeTest extends \Test\TestCase {
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testDeleteForbidden() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
@ -137,7 +151,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateComment() {
$msg = 'Hello Earth';
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
@ -173,7 +189,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateCommentLogException() {
$msg = null;
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
@ -210,7 +228,9 @@ class CommentsNodeTest extends \Test\TestCase {
* @expectedExceptionMessage Message exceeds allowed character limit of
*/
public function testUpdateCommentMessageTooLongException() {
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
@ -248,7 +268,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateForbiddenByUser() {
$msg = 'HaXX0r';
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
@ -281,7 +303,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateForbiddenByType() {
$msg = 'HaXX0r';
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->never())
->method('getUID');
@ -454,7 +478,11 @@ class CommentsNodeTest extends \Test\TestCase {
$this->userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($this->getMock('\OCP\IUser')));
->will($this->returnValue(
$this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock()
));
$properties = $this->node->getProperties(null);

View File

@ -55,8 +55,12 @@ class CommentsPluginTest extends \Test\TestCase {
->setMethods(['getRequestUri'])
->getMock();
$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->plugin = new CommentsPluginImplementation($this->commentsManager, $this->userSession);
}
@ -80,7 +84,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
$user = $this->getMock('OCP\IUser');
$user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
@ -174,7 +180,9 @@ class CommentsPluginTest extends \Test\TestCase {
$path = 'comments/files/666';
$user = $this->getMock('OCP\IUser');
$user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->never())
->method('getUID');
@ -256,7 +264,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
$user = $this->getMock('OCP\IUser');
$user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->never())
->method('getUID');
@ -342,7 +352,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
$user = $this->getMock('OCP\IUser');
$user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->never())
->method('getUID');
@ -430,7 +442,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
$user = $this->getMock('OCP\IUser');
$user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
@ -522,7 +536,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
$user = $this->getMock('OCP\IUser');
$user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
@ -599,7 +615,11 @@ class CommentsPluginTest 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')
@ -618,7 +638,11 @@ class CommentsPluginTest 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')

View File

@ -38,10 +38,18 @@ class EntityCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->logger = $this->getMock('\OCP\ILogger');
$this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')
->disableOriginalConstructor()
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder('\OCP\ILogger')
->disableOriginalConstructor()
->getMock();
$this->collection = new \OCA\DAV\Comments\EntityCollection(
'19',
@ -61,7 +69,11 @@ class EntityCollectionTest extends \Test\TestCase {
$this->commentsManager->expects($this->once())
->method('get')
->with('55')
->will($this->returnValue($this->getMock('\OCP\Comments\IComment')));
->will($this->returnValue(
$this->getMockBuilder('\OCP\Comments\IComment')
->disableOriginalConstructor()
->getMock()
));
$node = $this->collection->getChild('55');
$this->assertTrue($node instanceof \OCA\DAV\Comments\CommentNode);
@ -83,7 +95,11 @@ class EntityCollectionTest extends \Test\TestCase {
$this->commentsManager->expects($this->once())
->method('getForObject')
->with('files', '19')
->will($this->returnValue([$this->getMock('\OCP\Comments\IComment')]));
->will($this->returnValue([
$this->getMockBuilder('\OCP\Comments\IComment')
->disableOriginalConstructor()
->getMock()
]));
$result = $this->collection->getChildren();
@ -96,7 +112,11 @@ class EntityCollectionTest extends \Test\TestCase {
$this->commentsManager->expects($this->once())
->method('getForObject')
->with('files', '19', 5, 15, $dt)
->will($this->returnValue([$this->getMock('\OCP\Comments\IComment')]));
->will($this->returnValue([
$this->getMockBuilder('\OCP\Comments\IComment')
->disableOriginalConstructor()
->getMock()
]));
$result = $this->collection->findChildren(5, 15, $dt);

View File

@ -42,10 +42,18 @@ class EntityTypeCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->logger = $this->getMock('\OCP\ILogger');
$this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')
->disableOriginalConstructor()
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder('\OCP\ILogger')
->disableOriginalConstructor()
->getMock();
$instance = $this;

View File

@ -46,13 +46,23 @@ class RootCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
$this->user = $this->getMock('\OCP\IUser');
$this->user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')
->disableOriginalConstructor()
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$this->dispatcher = new EventDispatcher();
$this->logger = $this->getMock('\OCP\ILogger');
$this->logger = $this->getMockBuilder('\OCP\ILogger')
->disableOriginalConstructor()
->getMock();
$this->collection = new \OCA\DAV\Comments\RootCollection(
$this->commentsManager,

View File

@ -51,9 +51,15 @@ class PublicAuthTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->session = $this->getMock('\OCP\ISession');
$this->request = $this->getMock('\OCP\IRequest');
$this->shareManager = $this->getMock('\OCP\Share\IManager');
$this->session = $this->getMockBuilder('\OCP\ISession')
->disableOriginalConstructor()
->getMock();
$this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
$this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
->disableOriginalConstructor()
->getMock();
$this->auth = new \OCA\DAV\Connector\PublicAuth(
$this->request,
@ -86,7 +92,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testShareNoPassword() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->getMockBuilder('OCP\Share\IShare')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn(null);
$this->shareManager->expects($this->once())
@ -99,7 +107,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordFancyShareType() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->getMockBuilder('OCP\Share\IShare')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(42);
@ -114,7 +124,9 @@ class PublicAuthTest extends \Test\TestCase {
public function testSharePasswordRemote() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->getMockBuilder('OCP\Share\IShare')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_REMOTE);
@ -128,7 +140,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordLinkValidPassword() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->getMockBuilder('OCP\Share\IShare')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
@ -148,7 +162,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordLinkValidSession() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->getMockBuilder('OCP\Share\IShare')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');
@ -172,7 +188,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordLinkInvalidSession() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->getMockBuilder('OCP\Share\IShare')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');

View File

@ -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())

View File

@ -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')

View File

@ -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]
];
}

View File

@ -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));

View File

@ -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 = '/') {

View File

@ -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');

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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));

View File

@ -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);

View File

@ -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'));

View File

@ -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);
}

View File

@ -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]);

View File

@ -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()

View File

@ -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))

View File

@ -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) {

View File

@ -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()
);
}

View File

@ -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));

View File

@ -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')

View File

@ -47,9 +47,12 @@ class SystemTagMappingNodeTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
$this->user = $this->getMock('\OCP\IUser');
$this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
->getMock();
$this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
->getMock();
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
}
public function getMappingNode($tag = null) {

View File

@ -46,8 +46,10 @@ class SystemTagNodeTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->user = $this->getMock('\OCP\IUser');
$this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
->getMock();
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
}
protected function getTagNode($isAdmin = true, $tag = null) {

View File

@ -83,10 +83,14 @@ class SystemTagPluginTest extends \Test\TestCase {
$this->server = new \Sabre\DAV\Server($this->tree);
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->groupManager = $this->getMock('\OCP\IGroupManager');
$this->user = $this->getMock('\OCP\IUser');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
->getMock();
$this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')
->getMock();
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->getMock();
$this->userSession
->expects($this->any())
->method('getUser')

View File

@ -41,19 +41,23 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
->getMock();
}
public function getNode($isAdmin = true) {
$this->user = $this->getMock('\OCP\IUser');
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
$userSession = $this->getMock('\OCP\IUserSession');
$userSession = $this->getMockBuilder('\OCP\IUserSession')
->getMock();
$userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
$groupManager = $this->getMock('\OCP\IGroupManager');
$groupManager = $this->getMockBuilder('\OCP\IGroupManager')
->getMock();
$groupManager->expects($this->any())
->method('isAdmin')
->with('testuser')

View File

@ -46,10 +46,13 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
$this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
->getMock();
$this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
->getMock();
$this->user = $this->getMock('\OCP\IUser');
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
}
public function getNode() {

View File

@ -47,26 +47,33 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
$this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
$this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
->getMock();
$this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
->getMock();
$user = $this->getMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
$userSession = $this->getMock('\OCP\IUserSession');
$userSession = $this->getMockBuilder('\OCP\IUserSession')
->getMock();
$userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($user));
$groupManager = $this->getMock('\OCP\IGroupManager');
$groupManager = $this->getMockBuilder('\OCP\IGroupManager')
->getMock();
$groupManager->expects($this->any())
->method('isAdmin')
->with('testuser')
->will($this->returnValue(true));
$this->userFolder = $this->getMock('\OCP\Files\Folder');
$this->userFolder = $this->getMockBuilder('\OCP\Files\Folder')
->getMock();
$fileRoot = $this->getMock('\OCP\Files\IRootFolder');
$fileRoot = $this->getMockBuilder('\OCP\Files\IRootFolder')
->getMock();
$fileRoot->expects($this->any())
->method('getUserfolder')
->with('testuser')