diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
index 4ccc841157f7975a54e92782ea548d14e804135a..749a98e307ee0b70783eadfeabbb8c116133eb52 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 be680b219d8e67d145db092a03d8e13efe1b84a9..9b11c3b82a0ae48f69ec04cd8cc0aa83d6cb1e22 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 3a9dc144584b43d466057e4dcb6b703074d409ee..0679df4e2f7656b47d11a0c8572f787e2e5b1df9 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 f63b9acf13af3576d800c3ea543c7d3601e971d7..c9fde55c5271fade377de19ddbb234daa015ca5c 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 18b18ab8d3b855a0dafeed961ab14c0d8fc397da..e7b3dd548c7eda1dfb9ea9fa8c12068ae662ea1a 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 a43ef94a1b97f0c053070228244abb825bc5bdd5..74223e8d5ca63fb3ba0db62f5c98fcb34c7c8a70 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 d5a6c9405456ecf6f0945685e310414e9854720f..c96db595394c08edca99e9325754474ef73ccf4f 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 14fc99d6e8bfe2e3e66f6f1609aaaa83b8541dd3..771e9d4856989f972cf02fc1c824224a66d58d20 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 abf965f9d9b2941dd3a3108be8a4910bd57f4fb3..322db53d7b910c3801c128b8cf26672b1a2b2fea 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 bc67772ef8463561830695e6acc8da1263eaeba6..e985775f41ceb15aaa18996e81a026d70fbd314e 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 9564298f23afb5399d75226d0ffd9fd1507334a5..92798797d6ce789f5f6654757e7aea0e812925ad 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 3859e4f279066bfcbaff793546d7969bbe977126..890d11465a4e371c05d16ab4c4f3ac663f4049ff 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 6ade77e34f31e0ccddf7e9a02e29571ee791a93e..70ef523359873bea62bb23ac01f1849699366831 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 f4f5e13fcf8aac492585f516782e2f8e12b6dbeb..0fb012d95380129333778ce52e49d82d06dae1bc 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 66f0a80380740c0e2f6380024516614660e8db09..7511d6b02f7128c4214b1d755b813b8741fb6882 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 28e4bd7e836ac5f15c2967fde4c6e4591ed5b746..797f306c7ba6c58d951ca0c77104ef729b5f3937 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 44e9e17b6952bb7b3e127c3448150ec76f326329..61f78d13547967bdc3c19ac57ff18e6651a4f9b2 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 0e1224f596ab5b6a62fa304d12c936da4c34d42c..25960cc3cb8667e97799fdd25d3f2e8965ea9f1b 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 096e4439074f99b714579b8cd3af6c8392ea44ad..29d2ce469a1c3e5ba0f7b3c95a1d980326ec3063 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 0f404a6a16ce4c167aebb6507386856b8b3f388b..bb87027bd1d81dd10f95b9910d045d93f249277b 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 2b3f3e15d1a7162ffd9f0b5ebaa09ce2bba90fa7..9419296bd5b8c43010965b364759743787a92ea3 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 baf4259b2158d836df60265d18064c34b9a89878..71beccd079c2e53564fceca22c406524bfa4b8e0 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 ca7d09565cead97724b4b159ae44e296b5a17934..43e875d25d78d1134f690d6b94655d5e7f193d39 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 3c7eb6f72c33c47a409e9518cab407943ca9e1a5..328e99c9fbe4013afa6ad1e1a42303609c836cc7 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 96d4357660e511a7be414064f4764ddfb92ecab1..617a0bd5dfab4cfa86f1e41cf141f9bf593ef80c 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 c6a1bc3dd4b6e949829155c2913ca29c11b78780..bf827fd3585609c8368c8f89607891f47eaa814f 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 a69e21c9e322dedfafcf838693bcf4e89acb0f81..efa1f0a7a5c646f97ac0aa938b8a8c56ddb58645 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 292c66c003f998c601e53ef15b669f0bca0004d0..3e3f9e5994614189e98c9555d398b694fa60757f 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 b2d4384133d97d8ca19e97973e3fd1d95fb79eda..0c6446e2911191d762ce8c75b1df3fd6a75a62f2 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 96bd39de89900878c7e7ae93b0ebf5f70e10bf80..8e6e514971449cce0276195d10d1157385d2c653 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 038ba24aa6ddfa0d4e6d2122993a90c51d85b637..7e0e98eb78d049bca86a778fe393373671a06473 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 f5207ef18d9a55305f1d6b961760e85b8db7a425..0a6c6b9356069d9a0dc7b670f5597218ba8d5538 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 9cfcafc4ea656132df5fee021799bce53e195619..d8d955d89efbef64f066029e2e48b2efdc3ba973 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 b37a01af5fce5f9de0fc978acc21260bf3a1f001..05a8473133894165662b6b2917745bd05f808dfe 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 7eb38f9f1ecc075f3e4fb77242db883a683be993..cca781dc28e7d4e235f64f6ddbb576e4a45f8a29 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 2fb1f63b1e360ca516f5dae96d7676e53c53f223..628abe6689a67d5e465ce8d1d333a3c7a2ad6d7d 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')