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(); ->disableOriginalConstructor()->getMock();
$this->backend = $this->getMockBuilder('\OCA\DAV\CardDAV\CardDavBackend') $this->backend = $this->getMockBuilder('\OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->vCard = $this->getMock('Sabre\VObject\Component\VCard'); $this->vCard = $this->getMockBuilder('Sabre\VObject\Component\VCard')
$this->urlGenerator = $this->getMock('OCP\IURLGenerator'); ->disableOriginalConstructor()
->getMock();
$this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
->disableOriginalConstructor()
->getMock();
$this->addressBookImpl = new AddressBookImpl( $this->addressBookImpl = new AddressBookImpl(
$this->addressBook, $this->addressBook,

View File

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

View File

@ -57,7 +57,10 @@ class ImageExportPluginTest extends TestCase {
$this->server->tree = $this->tree; $this->server->tree = $this->tree;
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); $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); $this->plugin->initialize($this->server);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -586,7 +586,9 @@ class AuthTest extends TestCase {
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var IUser */ /** @var IUser */
$user = $this->getMock('OCP\IUser'); $user = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->method('getUID')->willReturn('MyTestUser'); $user->method('getUID')->willReturn('MyTestUser');
$this->userSession $this->userSession
->expects($this->any()) ->expects($this->any())

View File

@ -41,7 +41,9 @@ class BlockLegacyClientPluginTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->config = $this->getMock('\OCP\IConfig'); $this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
$this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config); $this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config);
} }
@ -66,7 +68,9 @@ class BlockLegacyClientPluginTest extends TestCase {
*/ */
public function testBeforeHandlerException($userAgent) { public function testBeforeHandlerException($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */ /** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface'); $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
$request $request
->expects($this->once()) ->expects($this->once())
->method('getHeader') ->method('getHeader')
@ -101,7 +105,9 @@ class BlockLegacyClientPluginTest extends TestCase {
*/ */
public function testBeforeHandlerSuccess($userAgent) { public function testBeforeHandlerSuccess($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */ /** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface'); $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
$request $request
->expects($this->once()) ->expects($this->once())
->method('getHeader') ->method('getHeader')
@ -119,7 +125,9 @@ class BlockLegacyClientPluginTest extends TestCase {
public function testBeforeHandlerNoUserAgent() { public function testBeforeHandlerNoUserAgent() {
/** @var \Sabre\HTTP\RequestInterface $request */ /** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface'); $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
$request $request
->expects($this->once()) ->expects($this->once())
->method('getHeader') ->method('getHeader')

View File

@ -35,8 +35,12 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager'); $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
$this->userSession = $this->getMock('\OCP\IUserSession'); ->disableOriginalConstructor()
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$this->server = $this->getMockBuilder('\Sabre\DAV\Server') $this->server = $this->getMockBuilder('\Sabre\DAV\Server')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -114,7 +118,11 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
public function userProvider() { public function userProvider() {
return [ return [
[$this->getMock('\OCP\IUser')], [
$this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock()
],
[null] [null]
]; ];
} }

View File

@ -67,7 +67,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$userId = $this->getUniqueID('testcustompropertiesuser'); $userId = $this->getUniqueID('testcustompropertiesuser');
$this->user = $this->getMock('\OCP\IUser'); $this->user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$this->user->expects($this->any()) $this->user->expects($this->any())
->method('getUID') ->method('getUID')
->will($this->returnValue($userId)); ->will($this->returnValue($userId));

View File

@ -39,8 +39,12 @@ class DirectoryTest extends \Test\TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->view = $this->getMock('OC\Files\View', array(), array(), '', false); $this->view = $this->getMockBuilder('OC\Files\View')
$this->info = $this->getMock('OC\Files\FileInfo', array(), array(), '', false); ->disableOriginalConstructor()
->getMock();
$this->info = $this->getMockBuilder('OC\Files\FileInfo')
->disableOriginalConstructor()
->getMock();
} }
private function getDir($path = '/') { private function getDir($path = '/') {

View File

@ -43,7 +43,9 @@ class DummyGetResponsePluginTest extends TestCase {
public function testInitialize() { public function testInitialize() {
/** @var \Sabre\DAV\Server $server */ /** @var \Sabre\DAV\Server $server */
$server = $this->getMock('\Sabre\DAV\Server'); $server = $this->getMockBuilder('\Sabre\DAV\Server')
->disableOriginalConstructor()
->getMock();
$server $server
->expects($this->once()) ->expects($this->once())
->method('on') ->method('on')
@ -55,9 +57,13 @@ class DummyGetResponsePluginTest extends TestCase {
public function testHttpGet() { public function testHttpGet() {
/** @var \Sabre\HTTP\RequestInterface $request */ /** @var \Sabre\HTTP\RequestInterface $request */
$request = $this->getMock('\Sabre\HTTP\RequestInterface'); $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
/** @var \Sabre\HTTP\ResponseInterface $response */ /** @var \Sabre\HTTP\ResponseInterface $response */
$response = $server = $this->getMock('\Sabre\HTTP\ResponseInterface'); $response = $server = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
->disableOriginalConstructor()
->getMock();
$response $response
->expects($this->once()) ->expects($this->once())
->method('setBody'); ->method('setBody');

View File

@ -47,7 +47,9 @@ class ForbiddenTest extends \Test\TestCase {
EOD; EOD;
$ex = new Forbidden($message, $retry); $ex = new Forbidden($message, $retry);
$server = $this->getMock('Sabre\DAV\Server'); $server = $this->getMockBuilder('Sabre\DAV\Server')
->disableOriginalConstructor()
->getMock();
$ex->serialize($server, $error); $ex->serialize($server, $error);
// assert // assert

View File

@ -48,7 +48,9 @@ class InvalidPathTest extends \Test\TestCase {
EOD; EOD;
$ex = new InvalidPath($message, $retry); $ex = new InvalidPath($message, $retry);
$server = $this->getMock('Sabre\DAV\Server'); $server = $this->getMockBuilder('Sabre\DAV\Server')
->disableOriginalConstructor()
->getMock();
$ex->serialize($server, $error); $ex->serialize($server, $error);
// assert // assert

View File

@ -42,7 +42,9 @@ class FakeLockerPluginTest extends TestCase {
public function testInitialize() { public function testInitialize() {
/** @var \Sabre\DAV\Server $server */ /** @var \Sabre\DAV\Server $server */
$server = $this->getMock('\Sabre\DAV\Server'); $server = $this->getMockBuilder('\Sabre\DAV\Server')
->disableOriginalConstructor()
->getMock();
$server $server
->expects($this->at(0)) ->expects($this->at(0))
->method('on') ->method('on')
@ -82,7 +84,9 @@ class FakeLockerPluginTest extends TestCase {
$propFind = $this->getMockBuilder('\Sabre\DAV\PropFind') $propFind = $this->getMockBuilder('\Sabre\DAV\PropFind')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$node = $this->getMock('\Sabre\DAV\INode'); $node = $this->getMockBuilder('\Sabre\DAV\INode')
->disableOriginalConstructor()
->getMock();
$propFind->expects($this->at(0)) $propFind->expects($this->at(0))
->method('handle') ->method('handle')
@ -137,15 +141,20 @@ class FakeLockerPluginTest extends TestCase {
* @param array $expected * @param array $expected
*/ */
public function testValidateTokens(array $input, 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->fakeLockerPlugin->validateTokens($request, $input);
$this->assertSame($expected, $input); $this->assertSame($expected, $input);
} }
public function testFakeLockProvider() { public function testFakeLockProvider() {
$request = $this->getMock('\Sabre\HTTP\RequestInterface'); $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
->disableOriginalConstructor()
->getMock();
$response = new Response(); $response = new Response();
$server = $this->getMock('\Sabre\DAV\Server'); $server = $this->getMockBuilder('\Sabre\DAV\Server')
->getMock();
$this->fakeLockerPlugin->initialize($server); $this->fakeLockerPlugin->initialize($server);
$request->expects($this->exactly(2)) $request->expects($this->exactly(2))
@ -160,8 +169,12 @@ class FakeLockerPluginTest extends TestCase {
} }
public function testFakeUnlockProvider() { public function testFakeUnlockProvider() {
$request = $this->getMock('\Sabre\HTTP\RequestInterface'); $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
$response = $this->getMock('\Sabre\HTTP\ResponseInterface'); ->disableOriginalConstructor()
->getMock();
$response = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
->disableOriginalConstructor()
->getMock();
$response->expects($this->once()) $response->expects($this->once())
->method('setStatus') ->method('setStatus')

View File

@ -65,7 +65,9 @@ class FileTest extends \Test\TestCase {
} }
private function getMockStorage() { private function getMockStorage() {
$storage = $this->getMock('\OCP\Files\Storage'); $storage = $this->getMockBuilder('\OCP\Files\Storage')
->disableOriginalConstructor()
->getMock();
$storage->expects($this->any()) $storage->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('home::someuser')); ->will($this->returnValue('home::someuser'));
@ -144,13 +146,14 @@ class FileTest extends \Test\TestCase {
*/ */
public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) { public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) {
// setup // setup
$storage = $this->getMock( $storage = $this->getMockBuilder('\OC\Files\Storage\Local')
'\OC\Files\Storage\Local', ->setMethods(['fopen'])
['fopen'], ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
[['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]] ->getMock();
);
\OC\Files\Filesystem::mount($storage, [], $this->user . '/'); \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()) $view->expects($this->atLeastOnce())
->method('resolvePath') ->method('resolvePath')
->will($this->returnCallback( ->will($this->returnCallback(
@ -202,13 +205,14 @@ class FileTest extends \Test\TestCase {
*/ */
public function testChunkedPutFails($thrownException, $expectedException, $checkPreviousClass = false) { public function testChunkedPutFails($thrownException, $expectedException, $checkPreviousClass = false) {
// setup // setup
$storage = $this->getMock( $storage = $this->getMockBuilder('\OC\Files\Storage\Local')
'\OC\Files\Storage\Local', ->setMethods(['fopen'])
['fopen'], ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
[['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]] ->getMock();
);
\OC\Files\Filesystem::mount($storage, [], $this->user . '/'); \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()) $view->expects($this->atLeastOnce())
->method('resolvePath') ->method('resolvePath')
->will($this->returnCallback( ->will($this->returnCallback(
@ -526,8 +530,9 @@ class FileTest extends \Test\TestCase {
*/ */
public function testSimplePutFailsSizeCheck() { public function testSimplePutFailsSizeCheck() {
// setup // setup
$view = $this->getMock('\OC\Files\View', $view = $this->getMockBuilder('\OC\Files\View')
array('rename', 'getRelativePath', 'filesize')); ->setMethods(['rename', 'getRelativePath', 'filesize'])
->getMock();
$view->expects($this->any()) $view->expects($this->any())
->method('rename') ->method('rename')
->withAnyParameters() ->withAnyParameters()
@ -643,7 +648,9 @@ class FileTest extends \Test\TestCase {
*/ */
public function testSimplePutInvalidChars() { public function testSimplePutInvalidChars() {
// setup // setup
$view = $this->getMock('\OC\Files\View', array('getRelativePath')); $view = $this->getMockBuilder('\OC\Files\View')
->setMethods(['getRelativePath'])
->getMock();
$view->expects($this->any()) $view->expects($this->any())
->method('getRelativePath') ->method('getRelativePath')
->will($this->returnArgument(0)); ->will($this->returnArgument(0));
@ -678,7 +685,9 @@ class FileTest extends \Test\TestCase {
*/ */
public function testSetNameInvalidChars() { public function testSetNameInvalidChars() {
// setup // setup
$view = $this->getMock('\OC\Files\View', array('getRelativePath')); $view = $this->getMockBuilder('\OC\Files\View')
->setMethods(['getRelativePath'])
->getMock();
$view->expects($this->any()) $view->expects($this->any())
->method('getRelativePath') ->method('getRelativePath')
@ -695,8 +704,9 @@ class FileTest extends \Test\TestCase {
*/ */
public function testUploadAbort() { public function testUploadAbort() {
// setup // setup
$view = $this->getMock('\OC\Files\View', $view = $this->getMockBuilder('\OC\Files\View')
array('rename', 'getRelativePath', 'filesize')); ->setMethods(['rename', 'getRelativePath', 'filesize'])
->getMock();
$view->expects($this->any()) $view->expects($this->any())
->method('rename') ->method('rename')
->withAnyParameters() ->withAnyParameters()
@ -740,8 +750,8 @@ class FileTest extends \Test\TestCase {
*/ */
public function testDeleteWhenAllowed() { public function testDeleteWhenAllowed() {
// setup // setup
$view = $this->getMock('\OC\Files\View', $view = $this->getMockBuilder('\OC\Files\View')
array()); ->getMock();
$view->expects($this->once()) $view->expects($this->once())
->method('unlink') ->method('unlink')
@ -762,8 +772,8 @@ class FileTest extends \Test\TestCase {
*/ */
public function testDeleteThrowsWhenDeletionNotAllowed() { public function testDeleteThrowsWhenDeletionNotAllowed() {
// setup // setup
$view = $this->getMock('\OC\Files\View', $view = $this->getMockBuilder('\OC\Files\View')
array()); ->getMock();
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => 0 'permissions' => 0
@ -780,8 +790,8 @@ class FileTest extends \Test\TestCase {
*/ */
public function testDeleteThrowsWhenDeletionFailed() { public function testDeleteThrowsWhenDeletionFailed() {
// setup // setup
$view = $this->getMock('\OC\Files\View', $view = $this->getMockBuilder('\OC\Files\View')
array()); ->getMock();
// but fails // but fails
$view->expects($this->once()) $view->expects($this->once())
@ -803,8 +813,8 @@ class FileTest extends \Test\TestCase {
*/ */
public function testDeleteThrowsWhenDeletionThrows() { public function testDeleteThrowsWhenDeletionThrows() {
// setup // setup
$view = $this->getMock('\OC\Files\View', $view = $this->getMockBuilder('\OC\Files\View')
array()); ->getMock();
// but fails // but fails
$view->expects($this->once()) $view->expects($this->once())
@ -953,7 +963,9 @@ class FileTest extends \Test\TestCase {
* @expectedException \Sabre\DAV\Exception\ServiceUnavailable * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
*/ */
public function testGetFopenFails() { public function testGetFopenFails() {
$view = $this->getMock('\OC\Files\View', ['fopen'], array()); $view = $this->getMockBuilder('\OC\Files\View')
->setMethods(['fopen'])
->getMock();
$view->expects($this->atLeastOnce()) $view->expects($this->atLeastOnce())
->method('fopen') ->method('fopen')
->will($this->returnValue(false)); ->will($this->returnValue(false));
@ -971,7 +983,9 @@ class FileTest extends \Test\TestCase {
* @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden
*/ */
public function testGetFopenThrows() { public function testGetFopenThrows() {
$view = $this->getMock('\OC\Files\View', ['fopen'], array()); $view = $this->getMockBuilder('\OC\Files\View')
->setMethods(['fopen'])
->getMock();
$view->expects($this->atLeastOnce()) $view->expects($this->atLeastOnce())
->method('fopen') ->method('fopen')
->willThrowException(new ForbiddenException('', true)); ->willThrowException(new ForbiddenException('', true));

View File

@ -89,11 +89,15 @@ class FilesPluginTest extends TestCase {
$this->view = $this->getMockBuilder('\OC\Files\View') $this->view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->config = $this->getMock('\OCP\IConfig'); $this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
$this->config->expects($this->any())->method('getSystemValue') $this->config->expects($this->any())->method('getSystemValue')
->with($this->equalTo('data-fingerprint'), $this->equalTo('')) ->with($this->equalTo('data-fingerprint'), $this->equalTo(''))
->willReturn('my_fingerprint'); ->willReturn('my_fingerprint');
$this->request = $this->getMock('\OCP\IRequest'); $this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
$this->plugin = new FilesPlugin( $this->plugin = new FilesPlugin(
$this->tree, $this->tree,
@ -275,7 +279,9 @@ class FilesPluginTest extends TestCase {
$this->tree, $this->tree,
$this->view, $this->view,
$this->config, $this->config,
$this->getMock('\OCP\IRequest'), $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock(),
true); true);
$this->plugin->initialize($this->server); $this->plugin->initialize($this->server);

View File

@ -82,11 +82,19 @@ class FilesReportPluginTest extends \Test\TestCase {
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager'); $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
$this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper'); ->disableOriginalConstructor()
$this->userSession = $this->getMock('\OCP\IUserSession'); ->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()) $user->expects($this->any())
->method('getUID') ->method('getUID')
->will($this->returnValue('testuser')); ->will($this->returnValue('testuser'));
@ -114,7 +122,11 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->tree->expects($this->any()) $this->tree->expects($this->any())
->method('getNodeForPath') ->method('getNodeForPath')
->with('/' . $path) ->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()) $this->server->expects($this->any())
->method('getRequestUri') ->method('getRequestUri')
@ -133,7 +145,11 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->tree->expects($this->any()) $this->tree->expects($this->any())
->method('getNodeForPath') ->method('getNodeForPath')
->with('/' . $path) ->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()) $this->server->expects($this->any())
->method('getRequestUri') ->method('getRequestUri')
@ -337,14 +353,18 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('getSize') ->method('getSize')
->will($this->returnValue(1024)); ->will($this->returnValue(1024));
$config = $this->getMock('\OCP\IConfig'); $config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
$this->server->addPlugin( $this->server->addPlugin(
new \OCA\DAV\Connector\Sabre\FilesPlugin( new \OCA\DAV\Connector\Sabre\FilesPlugin(
$this->tree, $this->tree,
$this->view, $this->view,
$config, $config,
$this->getMock('\OCP\IRequest') $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock()
) )
); );
$this->plugin->initialize($this->server); $this->plugin->initialize($this->server);
@ -494,7 +514,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin') ->method('isAdmin')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$tag1 = $this->getMock('\OCP\SystemTag\ISystemTag'); $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
->disableOriginalConstructor()
->getMock();
$tag1->expects($this->any()) $tag1->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
@ -502,7 +524,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible') ->method('isUserVisible')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$tag2 = $this->getMock('\OCP\SystemTag\ISystemTag'); $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
->disableOriginalConstructor()
->getMock();
$tag2->expects($this->any()) $tag2->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
@ -539,7 +563,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin') ->method('isAdmin')
->will($this->returnValue(false)); ->will($this->returnValue(false));
$tag1 = $this->getMock('\OCP\SystemTag\ISystemTag'); $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
->disableOriginalConstructor()
->getMock();
$tag1->expects($this->any()) $tag1->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
@ -547,7 +573,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible') ->method('isUserVisible')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$tag2 = $this->getMock('\OCP\SystemTag\ISystemTag'); $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
->disableOriginalConstructor()
->getMock();
$tag2->expects($this->any()) $tag2->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
@ -573,7 +601,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin') ->method('isAdmin')
->will($this->returnValue(false)); ->will($this->returnValue(false));
$tag1 = $this->getMock('\OCP\SystemTag\ISystemTag'); $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
->disableOriginalConstructor()
->getMock();
$tag1->expects($this->any()) $tag1->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
@ -581,7 +611,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible') ->method('isUserVisible')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$tag2 = $this->getMock('\OCP\SystemTag\ISystemTag'); $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
->disableOriginalConstructor()
->getMock();
$tag2->expects($this->any()) $tag2->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('123')); ->will($this->returnValue('123'));

View File

@ -40,7 +40,7 @@ class MaintenancePluginTest extends TestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->config = $this->getMock('\OCP\IConfig'); $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->maintenancePlugin = new MaintenancePlugin($this->config); $this->maintenancePlugin = new MaintenancePlugin($this->config);
} }

View File

@ -66,7 +66,9 @@ class NodeTest extends \Test\TestCase {
$info->expects($this->any()) $info->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue($type)); ->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); $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->assertEquals($expected, $node->getDavPermissions()); $this->assertEquals($expected, $node->getDavPermissions());
@ -116,10 +118,14 @@ class NodeTest extends \Test\TestCase {
* @dataProvider sharePermissionsProvider * @dataProvider sharePermissionsProvider
*/ */
public function testSharePermissions($type, $user, $permissions, $expected) { 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); $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'); $mountpoint->method('getMountPoint')->willReturn('myPath');
$shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock(); $shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock();
$share = $this->getMockBuilder('OCP\Share\IShare')->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('getType')->willReturn($type);
$info->method('getMountPoint')->willReturn($mountpoint); $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); $node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]); $this->invokePrivate($node, 'shareManager', [$shareManager]);

View File

@ -74,7 +74,9 @@ class TestDoubleFileView extends \OC\Files\View {
class ObjectTreeTest extends \Test\TestCase { class ObjectTreeTest extends \Test\TestCase {
public function getFileInfoMock() { public function getFileInfoMock() {
$mock = $this->getMock('\OCP\Files\FileInfo'); $mock = $this->getMockBuilder('\OCP\Files\FileInfo')
->disableOriginalConstructor()
->getMock();
$mock $mock
->expects($this->any()) ->expects($this->any())
->method('isDeletable') ->method('isDeletable')
@ -147,9 +149,10 @@ class ObjectTreeTest extends \Test\TestCase {
$info = new FileInfo('', null, null, array(), null); $info = new FileInfo('', null, null, array(), null);
$rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info); $rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
$objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree', $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree')
array('nodeExists', 'getNodeForPath'), ->setMethods(['nodeExists', 'getNodeForPath'])
array($rootDir, $view)); ->setConstructorArgs([$rootDir, $view])
->getMock();
$objectTree->expects($this->once()) $objectTree->expects($this->once())
->method('getNodeForPath') ->method('getNodeForPath')
@ -180,9 +183,15 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$mountManager = $this->getMock('\OC\Files\Mount\Manager'); $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
$view = $this->getMock('\OC\Files\View'); ->disableOriginalConstructor()
$fileInfo = $this->getMock('\OCP\Files\FileInfo'); ->getMock();
$view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
$fileInfo = $this->getMockBuilder('\OCP\Files\FileInfo')
->disableOriginalConstructor()
->getMock();
$fileInfo->expects($this->once()) $fileInfo->expects($this->once())
->method('getType') ->method('getType')
->will($this->returnValue($type)); ->will($this->returnValue($type));
@ -290,7 +299,9 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]); $storage = new Temporary([]);
$view = $this->getMock('\OC\Files\View', ['resolvePath']); $view = $this->getMockBuilder('\OC\Files\View')
->setMethods(['resolvePath'])
->getMock();
$view->expects($this->once()) $view->expects($this->once())
->method('resolvePath') ->method('resolvePath')
->will($this->returnCallback(function($path) use ($storage){ ->will($this->returnCallback(function($path) use ($storage){
@ -300,7 +311,8 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$mountManager = $this->getMock('\OC\Files\Mount\Manager'); $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
->getMock();
$tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$tree->init($rootNode, $view, $mountManager); $tree->init($rootNode, $view, $mountManager);
@ -314,7 +326,9 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]); $storage = new Temporary([]);
$view = $this->getMock('\OC\Files\View', ['resolvePath']); $view = $this->getMockBuilder('\OC\Files\View')
->setMethods(['resolvePath'])
->getMock();
$view->expects($this->any()) $view->expects($this->any())
->method('resolvePath') ->method('resolvePath')
->will($this->returnCallback(function ($path) use ($storage) { ->will($this->returnCallback(function ($path) use ($storage) {
@ -324,7 +338,8 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$mountManager = $this->getMock('\OC\Files\Mount\Manager'); $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
->getMock();
$tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$tree->init($rootNode, $view, $mountManager); $tree->init($rootNode, $view, $mountManager);
@ -347,9 +362,10 @@ class ObjectTreeTest extends \Test\TestCase {
$info = new FileInfo('', null, null, array(), null); $info = new FileInfo('', null, null, array(), null);
$rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info); $rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
$objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree', $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree')
array('nodeExists', 'getNodeForPath'), ->setMethods(['nodeExists', 'getNodeForPath'])
array($rootDir, $view)); ->setConstructorArgs([$rootDir, $view])
->getMock();
$sourceNode = $this->getMockBuilder('\Sabre\DAV\ICollection') $sourceNode = $this->getMockBuilder('\Sabre\DAV\ICollection')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@ -212,7 +212,10 @@ class QuotaPluginTest extends \Test\TestCase {
private function buildFileViewMock($quota, $checkedPath) { private function buildFileViewMock($quota, $checkedPath) {
// mock filesysten // 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()) $view->expects($this->any())
->method('free_space') ->method('free_space')
->with($this->identicalTo($checkedPath)) ->with($this->identicalTo($checkedPath))

View File

@ -35,7 +35,9 @@ use Test\Traits\EncryptionTrait;
class PartFileInRootUploadTest extends UploadTest { class PartFileInRootUploadTest extends UploadTest {
protected function setUp() { protected function setUp() {
$config = \OC::$server->getConfig(); $config = \OC::$server->getConfig();
$mockConfig = $this->getMock('\OCP\IConfig'); $mockConfig = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
$mockConfig->expects($this->any()) $mockConfig->expects($this->any())
->method('getSystemValue') ->method('getSystemValue')
->will($this->returnCallback(function ($key, $default) use ($config) { ->will($this->returnCallback(function ($key, $default) use ($config) {

View File

@ -62,7 +62,9 @@ abstract class RequestTest extends TestCase {
\OC::$server->getUserSession(), \OC::$server->getUserSession(),
\OC::$server->getMountManager(), \OC::$server->getMountManager(),
\OC::$server->getTagManager(), \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') $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->shareManager = $this->getMock('\OCP\Share\IManager'); $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
$user = $this->getMock('\OCP\IUser'); ->disableOriginalConstructor()
->getMock();
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getUID') ->method('getUID')
->will($this->returnValue('user1')); ->will($this->returnValue('user1'));
$userSession = $this->getMock('\OCP\IUserSession'); $userSession = $this->getMockBuilder('\OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
$userSession->expects($this->once()) $userSession->expects($this->once())
->method('getUser') ->method('getUser')
->will($this->returnValue($user)); ->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->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin(
$this->tree, $this->tree,
@ -92,7 +100,9 @@ class SharesPluginTest extends \Test\TestCase {
->will($this->returnValue('/subdir')); ->will($this->returnValue('/subdir'));
// node API nodes // node API nodes
$node = $this->getMock('\OCP\Files\Folder'); $node = $this->getMockBuilder('\OCP\Files\Folder')
->disableOriginalConstructor()
->getMock();
$this->userFolder->expects($this->once()) $this->userFolder->expects($this->once())
->method('get') ->method('get')
@ -168,15 +178,21 @@ class SharesPluginTest extends \Test\TestCase {
->will($this->returnValue('/subdir')); ->will($this->returnValue('/subdir'));
// node API nodes // node API nodes
$node = $this->getMock('\OCP\Files\Folder'); $node = $this->getMockBuilder('\OCP\Files\Folder')
->disableOriginalConstructor()
->getMock();
$node->expects($this->any()) $node->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue(123)); ->will($this->returnValue(123));
$node1 = $this->getMock('\OCP\Files\File'); $node1 = $this->getMockBuilder('\OCP\Files\File')
->disableOriginalConstructor()
->getMock();
$node1->expects($this->any()) $node1->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue(111)); ->will($this->returnValue(111));
$node2 = $this->getMock('\OCP\Files\File'); $node2 = $this->getMockBuilder('\OCP\Files\File')
->disableOriginalConstructor()
->getMock();
$node2->expects($this->any()) $node2->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue(222)); ->will($this->returnValue(222));

View File

@ -65,8 +65,12 @@ class TagsPluginTest extends \Test\TestCase {
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->tagger = $this->getMock('\OCP\ITags'); $this->tagger = $this->getMockBuilder('\OCP\ITags')
$this->tagManager = $this->getMock('\OCP\ITagManager'); ->disableOriginalConstructor()
->getMock();
$this->tagManager = $this->getMockBuilder('\OCP\ITagManager')
->disableOriginalConstructor()
->getMock();
$this->tagManager->expects($this->any()) $this->tagManager->expects($this->any())
->method('load') ->method('load')
->with('files') ->with('files')

View File

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

View File

@ -46,8 +46,10 @@ class SystemTagNodeTest extends \Test\TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager'); $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
$this->user = $this->getMock('\OCP\IUser'); ->getMock();
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
} }
protected function getTagNode($isAdmin = true, $tag = null) { 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->server = new \Sabre\DAV\Server($this->tree);
$this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager'); $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
$this->groupManager = $this->getMock('\OCP\IGroupManager'); ->getMock();
$this->user = $this->getMock('\OCP\IUser'); $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')
$this->userSession = $this->getMock('\OCP\IUserSession'); ->getMock();
$this->user = $this->getMockBuilder('\OCP\IUser')
->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')
->getMock();
$this->userSession $this->userSession
->expects($this->any()) ->expects($this->any())
->method('getUser') ->method('getUser')

View File

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

View File

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

View File

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