diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-15 09:52:46 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-15 09:52:46 +0200 |
commit | 2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4 (patch) | |
tree | b43ce551bf0a4ea1bd78de7084d3814f35beb12f /apps/dav/tests/unit/Comments | |
parent | 813b58ab947222f983fe25d56781f1f43c840538 (diff) | |
download | nextcloud-server-2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4.tar.gz nextcloud-server-2fcb24166f8ac77a49947f14bbeaf0f1bec5dfa4.zip |
Fix PHPUnit 5.4 warnings in DAV app
* getMock is deprecated
Diffstat (limited to 'apps/dav/tests/unit/Comments')
5 files changed, 130 insertions, 40 deletions
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, |