diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-07-15 11:14:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-15 11:14:15 +0200 |
commit | ab6db739fa1ff9c8f1b0302b95fad807d6431ab5 (patch) | |
tree | c595a2178506b741bf8030d0e909b3923025752c /apps/dav | |
parent | 5bfa95848494d71456954d92749d99b3cb87357c (diff) | |
parent | 2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4 (diff) | |
download | nextcloud-server-ab6db739fa1ff9c8f1b0302b95fad807d6431ab5.tar.gz nextcloud-server-ab6db739fa1ff9c8f1b0302b95fad807d6431ab5.zip |
Merge pull request #407 from nextcloud/dav_phpunit_fixes
Fix PHPUnit 5.4 warnings in DAV app
Diffstat (limited to 'apps/dav')
36 files changed, 472 insertions, 179 deletions
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php index 4ccc841157f..749a98e307e 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php @@ -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, diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php index be680b219d8..9b11c3b82a0 100644 --- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php @@ -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(''); diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php index 3a9dc144584..0679df4e2f7 100644 --- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php +++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php @@ -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); } diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index f63b9acf13a..c9fde55c527 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -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([ diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php index 18b18ab8d3b..e7b3dd548c7 100644 --- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php +++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php @@ -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); diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php index a43ef94a1b9..74223e8d5ca 100644 --- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php +++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php @@ -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') diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php index d5a6c940545..c96db595394 100644 --- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php @@ -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); diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php index 14fc99d6e8b..771e9d48569 100644 --- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php @@ -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; diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php index abf965f9d9b..322db53d7b9 100644 --- a/apps/dav/tests/unit/Comments/RootCollectionTest.php +++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php @@ -46,13 +46,23 @@ class RootCollectionTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->user = $this->getMock('\OCP\IUser'); - - $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager'); - $this->userManager = $this->getMock('\OCP\IUserManager'); - $this->userSession = $this->getMock('\OCP\IUserSession'); + $this->user = $this->getMockBuilder('\OCP\IUser') + ->disableOriginalConstructor() + ->getMock(); + + $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, diff --git a/apps/dav/tests/unit/Connector/PublicAuthTest.php b/apps/dav/tests/unit/Connector/PublicAuthTest.php index bc67772ef84..e985775f41c 100644 --- a/apps/dav/tests/unit/Connector/PublicAuthTest.php +++ b/apps/dav/tests/unit/Connector/PublicAuthTest.php @@ -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'); diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php index 9564298f23a..92798797d6c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php @@ -586,7 +586,9 @@ class AuthTest extends TestCase { ->disableOriginalConstructor() ->getMock(); /** @var IUser */ - $user = $this->getMock('OCP\IUser'); + $user = $this->getMockBuilder('OCP\IUser') + ->disableOriginalConstructor() + ->getMock(); $user->method('getUID')->willReturn('MyTestUser'); $this->userSession ->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php index 3859e4f2790..890d11465a4 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php @@ -41,7 +41,9 @@ class BlockLegacyClientPluginTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMock('\OCP\IConfig'); + $this->config = $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock(); $this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config); } @@ -66,7 +68,9 @@ class BlockLegacyClientPluginTest extends TestCase { */ public function testBeforeHandlerException($userAgent) { /** @var \Sabre\HTTP\RequestInterface $request */ - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); $request ->expects($this->once()) ->method('getHeader') @@ -101,7 +105,9 @@ class BlockLegacyClientPluginTest extends TestCase { */ public function testBeforeHandlerSuccess($userAgent) { /** @var \Sabre\HTTP\RequestInterface $request */ - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); $request ->expects($this->once()) ->method('getHeader') @@ -119,7 +125,9 @@ class BlockLegacyClientPluginTest extends TestCase { public function testBeforeHandlerNoUserAgent() { /** @var \Sabre\HTTP\RequestInterface $request */ - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); $request ->expects($this->once()) ->method('getHeader') diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php index 6ade77e34f3..70ef5233598 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php @@ -35,8 +35,12 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager'); - $this->userSession = $this->getMock('\OCP\IUserSession'); + $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + ->disableOriginalConstructor() + ->getMock(); + $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + ->disableOriginalConstructor() + ->getMock(); $this->server = $this->getMockBuilder('\Sabre\DAV\Server') ->disableOriginalConstructor() @@ -114,7 +118,11 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { public function userProvider() { return [ - [$this->getMock('\OCP\IUser')], + [ + $this->getMockBuilder('\OCP\IUser') + ->disableOriginalConstructor() + ->getMock() + ], [null] ]; } diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index f4f5e13fcf8..0fb012d9538 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -67,7 +67,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase { $userId = $this->getUniqueID('testcustompropertiesuser'); - $this->user = $this->getMock('\OCP\IUser'); + $this->user = $this->getMockBuilder('\OCP\IUser') + ->disableOriginalConstructor() + ->getMock(); $this->user->expects($this->any()) ->method('getUID') ->will($this->returnValue($userId)); diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index 66f0a803807..7511d6b02f7 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -39,8 +39,12 @@ class DirectoryTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->view = $this->getMock('OC\Files\View', array(), array(), '', false); - $this->info = $this->getMock('OC\Files\FileInfo', array(), array(), '', false); + $this->view = $this->getMockBuilder('OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); + $this->info = $this->getMockBuilder('OC\Files\FileInfo') + ->disableOriginalConstructor() + ->getMock(); } private function getDir($path = '/') { diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php index 28e4bd7e836..797f306c7ba 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php @@ -43,7 +43,9 @@ class DummyGetResponsePluginTest extends TestCase { public function testInitialize() { /** @var \Sabre\DAV\Server $server */ - $server = $this->getMock('\Sabre\DAV\Server'); + $server = $this->getMockBuilder('\Sabre\DAV\Server') + ->disableOriginalConstructor() + ->getMock(); $server ->expects($this->once()) ->method('on') @@ -55,9 +57,13 @@ class DummyGetResponsePluginTest extends TestCase { public function testHttpGet() { /** @var \Sabre\HTTP\RequestInterface $request */ - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); /** @var \Sabre\HTTP\ResponseInterface $response */ - $response = $server = $this->getMock('\Sabre\HTTP\ResponseInterface'); + $response = $server = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); $response ->expects($this->once()) ->method('setBody'); diff --git a/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php b/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php index 44e9e17b695..61f78d13547 100644 --- a/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php @@ -47,7 +47,9 @@ class ForbiddenTest extends \Test\TestCase { EOD; $ex = new Forbidden($message, $retry); - $server = $this->getMock('Sabre\DAV\Server'); + $server = $this->getMockBuilder('Sabre\DAV\Server') + ->disableOriginalConstructor() + ->getMock(); $ex->serialize($server, $error); // assert diff --git a/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php b/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php index 0e1224f596a..25960cc3cb8 100644 --- a/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php @@ -48,7 +48,9 @@ class InvalidPathTest extends \Test\TestCase { EOD; $ex = new InvalidPath($message, $retry); - $server = $this->getMock('Sabre\DAV\Server'); + $server = $this->getMockBuilder('Sabre\DAV\Server') + ->disableOriginalConstructor() + ->getMock(); $ex->serialize($server, $error); // assert diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index 096e4439074..29d2ce469a1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -42,7 +42,9 @@ class FakeLockerPluginTest extends TestCase { public function testInitialize() { /** @var \Sabre\DAV\Server $server */ - $server = $this->getMock('\Sabre\DAV\Server'); + $server = $this->getMockBuilder('\Sabre\DAV\Server') + ->disableOriginalConstructor() + ->getMock(); $server ->expects($this->at(0)) ->method('on') @@ -82,7 +84,9 @@ class FakeLockerPluginTest extends TestCase { $propFind = $this->getMockBuilder('\Sabre\DAV\PropFind') ->disableOriginalConstructor() ->getMock(); - $node = $this->getMock('\Sabre\DAV\INode'); + $node = $this->getMockBuilder('\Sabre\DAV\INode') + ->disableOriginalConstructor() + ->getMock(); $propFind->expects($this->at(0)) ->method('handle') @@ -137,15 +141,20 @@ class FakeLockerPluginTest extends TestCase { * @param array $expected */ public function testValidateTokens(array $input, array $expected) { - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); $this->fakeLockerPlugin->validateTokens($request, $input); $this->assertSame($expected, $input); } public function testFakeLockProvider() { - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); $response = new Response(); - $server = $this->getMock('\Sabre\DAV\Server'); + $server = $this->getMockBuilder('\Sabre\DAV\Server') + ->getMock(); $this->fakeLockerPlugin->initialize($server); $request->expects($this->exactly(2)) @@ -160,8 +169,12 @@ class FakeLockerPluginTest extends TestCase { } public function testFakeUnlockProvider() { - $request = $this->getMock('\Sabre\HTTP\RequestInterface'); - $response = $this->getMock('\Sabre\HTTP\ResponseInterface'); + $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); + $response = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); $response->expects($this->once()) ->method('setStatus') diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 0f404a6a16c..bb87027bd1d 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -65,7 +65,9 @@ class FileTest extends \Test\TestCase { } private function getMockStorage() { - $storage = $this->getMock('\OCP\Files\Storage'); + $storage = $this->getMockBuilder('\OCP\Files\Storage') + ->disableOriginalConstructor() + ->getMock(); $storage->expects($this->any()) ->method('getId') ->will($this->returnValue('home::someuser')); @@ -144,13 +146,14 @@ class FileTest extends \Test\TestCase { */ public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) { // setup - $storage = $this->getMock( - '\OC\Files\Storage\Local', - ['fopen'], - [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]] - ); + $storage = $this->getMockBuilder('\OC\Files\Storage\Local') + ->setMethods(['fopen']) + ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]) + ->getMock(); \OC\Files\Filesystem::mount($storage, [], $this->user . '/'); - $view = $this->getMock('\OC\Files\View', array('getRelativePath', 'resolvePath'), array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['getRelativePath', 'resolvePath']) + ->getMock(); $view->expects($this->atLeastOnce()) ->method('resolvePath') ->will($this->returnCallback( @@ -202,13 +205,14 @@ class FileTest extends \Test\TestCase { */ public function testChunkedPutFails($thrownException, $expectedException, $checkPreviousClass = false) { // setup - $storage = $this->getMock( - '\OC\Files\Storage\Local', - ['fopen'], - [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]] - ); + $storage = $this->getMockBuilder('\OC\Files\Storage\Local') + ->setMethods(['fopen']) + ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]) + ->getMock(); \OC\Files\Filesystem::mount($storage, [], $this->user . '/'); - $view = $this->getMock('\OC\Files\View', ['getRelativePath', 'resolvePath'], []); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['getRelativePath', 'resolvePath']) + ->getMock(); $view->expects($this->atLeastOnce()) ->method('resolvePath') ->will($this->returnCallback( @@ -526,8 +530,9 @@ class FileTest extends \Test\TestCase { */ public function testSimplePutFailsSizeCheck() { // setup - $view = $this->getMock('\OC\Files\View', - array('rename', 'getRelativePath', 'filesize')); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['rename', 'getRelativePath', 'filesize']) + ->getMock(); $view->expects($this->any()) ->method('rename') ->withAnyParameters() @@ -643,7 +648,9 @@ class FileTest extends \Test\TestCase { */ public function testSimplePutInvalidChars() { // setup - $view = $this->getMock('\OC\Files\View', array('getRelativePath')); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['getRelativePath']) + ->getMock(); $view->expects($this->any()) ->method('getRelativePath') ->will($this->returnArgument(0)); @@ -678,7 +685,9 @@ class FileTest extends \Test\TestCase { */ public function testSetNameInvalidChars() { // setup - $view = $this->getMock('\OC\Files\View', array('getRelativePath')); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['getRelativePath']) + ->getMock(); $view->expects($this->any()) ->method('getRelativePath') @@ -695,8 +704,9 @@ class FileTest extends \Test\TestCase { */ public function testUploadAbort() { // setup - $view = $this->getMock('\OC\Files\View', - array('rename', 'getRelativePath', 'filesize')); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['rename', 'getRelativePath', 'filesize']) + ->getMock(); $view->expects($this->any()) ->method('rename') ->withAnyParameters() @@ -740,8 +750,8 @@ class FileTest extends \Test\TestCase { */ public function testDeleteWhenAllowed() { // setup - $view = $this->getMock('\OC\Files\View', - array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->getMock(); $view->expects($this->once()) ->method('unlink') @@ -762,8 +772,8 @@ class FileTest extends \Test\TestCase { */ public function testDeleteThrowsWhenDeletionNotAllowed() { // setup - $view = $this->getMock('\OC\Files\View', - array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->getMock(); $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( 'permissions' => 0 @@ -780,8 +790,8 @@ class FileTest extends \Test\TestCase { */ public function testDeleteThrowsWhenDeletionFailed() { // setup - $view = $this->getMock('\OC\Files\View', - array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->getMock(); // but fails $view->expects($this->once()) @@ -803,8 +813,8 @@ class FileTest extends \Test\TestCase { */ public function testDeleteThrowsWhenDeletionThrows() { // setup - $view = $this->getMock('\OC\Files\View', - array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->getMock(); // but fails $view->expects($this->once()) @@ -953,7 +963,9 @@ class FileTest extends \Test\TestCase { * @expectedException \Sabre\DAV\Exception\ServiceUnavailable */ public function testGetFopenFails() { - $view = $this->getMock('\OC\Files\View', ['fopen'], array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['fopen']) + ->getMock(); $view->expects($this->atLeastOnce()) ->method('fopen') ->will($this->returnValue(false)); @@ -971,7 +983,9 @@ class FileTest extends \Test\TestCase { * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden */ public function testGetFopenThrows() { - $view = $this->getMock('\OC\Files\View', ['fopen'], array()); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['fopen']) + ->getMock(); $view->expects($this->atLeastOnce()) ->method('fopen') ->willThrowException(new ForbiddenException('', true)); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index 2b3f3e15d1a..9419296bd5b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -89,11 +89,15 @@ class FilesPluginTest extends TestCase { $this->view = $this->getMockBuilder('\OC\Files\View') ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMock('\OCP\IConfig'); + $this->config = $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock(); $this->config->expects($this->any())->method('getSystemValue') ->with($this->equalTo('data-fingerprint'), $this->equalTo('')) ->willReturn('my_fingerprint'); - $this->request = $this->getMock('\OCP\IRequest'); + $this->request = $this->getMockBuilder('\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(); $this->plugin = new FilesPlugin( $this->tree, @@ -275,7 +279,9 @@ class FilesPluginTest extends TestCase { $this->tree, $this->view, $this->config, - $this->getMock('\OCP\IRequest'), + $this->getMockBuilder('\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock(), true); $this->plugin->initialize($this->server); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index baf4259b215..71beccd079c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -82,11 +82,19 @@ class FilesReportPluginTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); - $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager'); - $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper'); - $this->userSession = $this->getMock('\OCP\IUserSession'); + $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + ->disableOriginalConstructor() + ->getMock(); + $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') + ->disableOriginalConstructor() + ->getMock(); + $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + ->disableOriginalConstructor() + ->getMock(); - $user = $this->getMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser') + ->disableOriginalConstructor() + ->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('testuser')); @@ -114,7 +122,11 @@ class FilesReportPluginTest extends \Test\TestCase { $this->tree->expects($this->any()) ->method('getNodeForPath') ->with('/' . $path) - ->will($this->returnValue($this->getMock('\Sabre\DAV\INode'))); + ->will($this->returnValue( + $this->getMockBuilder('\Sabre\DAV\INode') + ->disableOriginalConstructor() + ->getMock() + )); $this->server->expects($this->any()) ->method('getRequestUri') @@ -133,7 +145,11 @@ class FilesReportPluginTest extends \Test\TestCase { $this->tree->expects($this->any()) ->method('getNodeForPath') ->with('/' . $path) - ->will($this->returnValue($this->getMock('\Sabre\DAV\INode'))); + ->will($this->returnValue( + $this->getMockBuilder('\Sabre\DAV\INode') + ->disableOriginalConstructor() + ->getMock() + )); $this->server->expects($this->any()) ->method('getRequestUri') @@ -337,14 +353,18 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('getSize') ->will($this->returnValue(1024)); - $config = $this->getMock('\OCP\IConfig'); + $config = $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock(); $this->server->addPlugin( new \OCA\DAV\Connector\Sabre\FilesPlugin( $this->tree, $this->view, $config, - $this->getMock('\OCP\IRequest') + $this->getMockBuilder('\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock() ) ); $this->plugin->initialize($this->server); @@ -494,7 +514,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isAdmin') ->will($this->returnValue(true)); - $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag'); + $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + ->disableOriginalConstructor() + ->getMock(); $tag1->expects($this->any()) ->method('getId') ->will($this->returnValue('123')); @@ -502,7 +524,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isUserVisible') ->will($this->returnValue(true)); - $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag'); + $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + ->disableOriginalConstructor() + ->getMock(); $tag2->expects($this->any()) ->method('getId') ->will($this->returnValue('123')); @@ -539,7 +563,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isAdmin') ->will($this->returnValue(false)); - $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag'); + $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + ->disableOriginalConstructor() + ->getMock(); $tag1->expects($this->any()) ->method('getId') ->will($this->returnValue('123')); @@ -547,7 +573,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isUserVisible') ->will($this->returnValue(true)); - $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag'); + $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + ->disableOriginalConstructor() + ->getMock(); $tag2->expects($this->any()) ->method('getId') ->will($this->returnValue('123')); @@ -573,7 +601,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isAdmin') ->will($this->returnValue(false)); - $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag'); + $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + ->disableOriginalConstructor() + ->getMock(); $tag1->expects($this->any()) ->method('getId') ->will($this->returnValue('123')); @@ -581,7 +611,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isUserVisible') ->will($this->returnValue(true)); - $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag'); + $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + ->disableOriginalConstructor() + ->getMock(); $tag2->expects($this->any()) ->method('getId') ->will($this->returnValue('123')); diff --git a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php index ca7d09565ce..43e875d25d7 100644 --- a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php @@ -40,7 +40,7 @@ class MaintenancePluginTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMock('\OCP\IConfig'); + $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); $this->maintenancePlugin = new MaintenancePlugin($this->config); } diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index 3c7eb6f72c3..328e99c9fbe 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -66,7 +66,9 @@ class NodeTest extends \Test\TestCase { $info->expects($this->any()) ->method('getType') ->will($this->returnValue($type)); - $view = $this->getMock('\OC\Files\View'); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); $node = new \OCA\DAV\Connector\Sabre\File($view, $info); $this->assertEquals($expected, $node->getDavPermissions()); @@ -116,10 +118,14 @@ class NodeTest extends \Test\TestCase { * @dataProvider sharePermissionsProvider */ public function testSharePermissions($type, $user, $permissions, $expected) { - $storage = $this->getMock('\OCP\Files\Storage'); + $storage = $this->getMockBuilder('\OCP\Files\Storage') + ->disableOriginalConstructor() + ->getMock(); $storage->method('getPermissions')->willReturn($permissions); - $mountpoint = $this->getMock('\OCP\Files\Mount\IMountPoint'); + $mountpoint = $this->getMockBuilder('\OCP\Files\Mount\IMountPoint') + ->disableOriginalConstructor() + ->getMock(); $mountpoint->method('getMountPoint')->willReturn('myPath'); $shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock(); $share = $this->getMockBuilder('OCP\Share\IShare')->disableOriginalConstructor()->getMock(); @@ -142,7 +148,9 @@ class NodeTest extends \Test\TestCase { $info->method('getType')->willReturn($type); $info->method('getMountPoint')->willReturn($mountpoint); - $view = $this->getMock('\OC\Files\View'); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); $node = new \OCA\DAV\Connector\Sabre\File($view, $info); $this->invokePrivate($node, 'shareManager', [$shareManager]); diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index 96d4357660e..617a0bd5dfa 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -74,7 +74,9 @@ class TestDoubleFileView extends \OC\Files\View { class ObjectTreeTest extends \Test\TestCase { public function getFileInfoMock() { - $mock = $this->getMock('\OCP\Files\FileInfo'); + $mock = $this->getMockBuilder('\OCP\Files\FileInfo') + ->disableOriginalConstructor() + ->getMock(); $mock ->expects($this->any()) ->method('isDeletable') @@ -147,9 +149,10 @@ class ObjectTreeTest extends \Test\TestCase { $info = new FileInfo('', null, null, array(), null); $rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info); - $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree', - array('nodeExists', 'getNodeForPath'), - array($rootDir, $view)); + $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree') + ->setMethods(['nodeExists', 'getNodeForPath']) + ->setConstructorArgs([$rootDir, $view]) + ->getMock(); $objectTree->expects($this->once()) ->method('getNodeForPath') @@ -180,9 +183,15 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMock('\OC\Files\Mount\Manager'); - $view = $this->getMock('\OC\Files\View'); - $fileInfo = $this->getMock('\OCP\Files\FileInfo'); + $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + ->disableOriginalConstructor() + ->getMock(); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); + $fileInfo = $this->getMockBuilder('\OCP\Files\FileInfo') + ->disableOriginalConstructor() + ->getMock(); $fileInfo->expects($this->once()) ->method('getType') ->will($this->returnValue($type)); @@ -290,7 +299,9 @@ class ObjectTreeTest extends \Test\TestCase { $storage = new Temporary([]); - $view = $this->getMock('\OC\Files\View', ['resolvePath']); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['resolvePath']) + ->getMock(); $view->expects($this->once()) ->method('resolvePath') ->will($this->returnCallback(function($path) use ($storage){ @@ -300,7 +311,8 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMock('\OC\Files\Mount\Manager'); + $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + ->getMock(); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); $tree->init($rootNode, $view, $mountManager); @@ -314,7 +326,9 @@ class ObjectTreeTest extends \Test\TestCase { $storage = new Temporary([]); - $view = $this->getMock('\OC\Files\View', ['resolvePath']); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['resolvePath']) + ->getMock(); $view->expects($this->any()) ->method('resolvePath') ->will($this->returnCallback(function ($path) use ($storage) { @@ -324,7 +338,8 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMock('\OC\Files\Mount\Manager'); + $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + ->getMock(); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); $tree->init($rootNode, $view, $mountManager); @@ -347,9 +362,10 @@ class ObjectTreeTest extends \Test\TestCase { $info = new FileInfo('', null, null, array(), null); $rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info); - $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree', - array('nodeExists', 'getNodeForPath'), - array($rootDir, $view)); + $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree') + ->setMethods(['nodeExists', 'getNodeForPath']) + ->setConstructorArgs([$rootDir, $view]) + ->getMock(); $sourceNode = $this->getMockBuilder('\Sabre\DAV\ICollection') ->disableOriginalConstructor() diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index c6a1bc3dd4b..bf827fd3585 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -212,7 +212,10 @@ class QuotaPluginTest extends \Test\TestCase { private function buildFileViewMock($quota, $checkedPath) { // mock filesysten - $view = $this->getMock('\OC\Files\View', array('free_space'), array(), '', false); + $view = $this->getMockBuilder('\OC\Files\View') + ->setMethods(['free_space']) + ->disableOriginalConstructor() + ->getMock(); $view->expects($this->any()) ->method('free_space') ->with($this->identicalTo($checkedPath)) diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php index a69e21c9e32..efa1f0a7a5c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php @@ -35,7 +35,9 @@ use Test\Traits\EncryptionTrait; class PartFileInRootUploadTest extends UploadTest { protected function setUp() { $config = \OC::$server->getConfig(); - $mockConfig = $this->getMock('\OCP\IConfig'); + $mockConfig = $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock(); $mockConfig->expects($this->any()) ->method('getSystemValue') ->will($this->returnCallback(function ($key, $default) use ($config) { diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php index 292c66c003f..3e3f9e59946 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php @@ -62,7 +62,9 @@ abstract class RequestTest extends TestCase { \OC::$server->getUserSession(), \OC::$server->getMountManager(), \OC::$server->getTagManager(), - $this->getMock('\OCP\IRequest') + $this->getMockBuilder('\OCP\IRequest') + ->disableOriginalConstructor() + ->getMock() ); } diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index b2d4384133d..0c6446e2911 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -56,17 +56,25 @@ class SharesPluginTest extends \Test\TestCase { $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') ->disableOriginalConstructor() ->getMock(); - $this->shareManager = $this->getMock('\OCP\Share\IManager'); - $user = $this->getMock('\OCP\IUser'); + $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager') + ->disableOriginalConstructor() + ->getMock(); + $user = $this->getMockBuilder('\OCP\IUser') + ->disableOriginalConstructor() + ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('user1')); - $userSession = $this->getMock('\OCP\IUserSession'); + $userSession = $this->getMockBuilder('\OCP\IUserSession') + ->disableOriginalConstructor() + ->getMock(); $userSession->expects($this->once()) ->method('getUser') ->will($this->returnValue($user)); - $this->userFolder = $this->getMock('\OCP\Files\Folder'); + $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder') + ->disableOriginalConstructor() + ->getMock(); $this->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin( $this->tree, @@ -92,7 +100,9 @@ class SharesPluginTest extends \Test\TestCase { ->will($this->returnValue('/subdir')); // node API nodes - $node = $this->getMock('\OCP\Files\Folder'); + $node = $this->getMockBuilder('\OCP\Files\Folder') + ->disableOriginalConstructor() + ->getMock(); $this->userFolder->expects($this->once()) ->method('get') @@ -168,15 +178,21 @@ class SharesPluginTest extends \Test\TestCase { ->will($this->returnValue('/subdir')); // node API nodes - $node = $this->getMock('\OCP\Files\Folder'); + $node = $this->getMockBuilder('\OCP\Files\Folder') + ->disableOriginalConstructor() + ->getMock(); $node->expects($this->any()) ->method('getId') ->will($this->returnValue(123)); - $node1 = $this->getMock('\OCP\Files\File'); + $node1 = $this->getMockBuilder('\OCP\Files\File') + ->disableOriginalConstructor() + ->getMock(); $node1->expects($this->any()) ->method('getId') ->will($this->returnValue(111)); - $node2 = $this->getMock('\OCP\Files\File'); + $node2 = $this->getMockBuilder('\OCP\Files\File') + ->disableOriginalConstructor() + ->getMock(); $node2->expects($this->any()) ->method('getId') ->will($this->returnValue(222)); diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index 96bd39de899..8e6e5149714 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -65,8 +65,12 @@ class TagsPluginTest extends \Test\TestCase { $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') ->disableOriginalConstructor() ->getMock(); - $this->tagger = $this->getMock('\OCP\ITags'); - $this->tagManager = $this->getMock('\OCP\ITagManager'); + $this->tagger = $this->getMockBuilder('\OCP\ITags') + ->disableOriginalConstructor() + ->getMock(); + $this->tagManager = $this->getMockBuilder('\OCP\ITagManager') + ->disableOriginalConstructor() + ->getMock(); $this->tagManager->expects($this->any()) ->method('load') ->with('files') diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php index 038ba24aa6d..7e0e98eb78d 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php @@ -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) { diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php index f5207ef18d9..0a6c6b93560 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php @@ -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) { diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index 9cfcafc4ea6..d8d955d89ef 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -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') diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index b37a01af5fc..05a84731338 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -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') diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php index 7eb38f9f1ec..cca781dc28e 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php @@ -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() { diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index 2fb1f63b1e3..628abe6689a 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -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') |