diff options
Diffstat (limited to 'apps/dav/tests/unit/Comments')
5 files changed, 102 insertions, 73 deletions
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php index 226aa57598c..57a15a6dc76 100644 --- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php +++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php @@ -26,8 +26,13 @@ namespace OCA\DAV\Tests\unit\Comments; use OCA\DAV\Comments\CommentNode; +use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; use OCP\Comments\MessageTooLongException; +use OCP\ILogger; +use OCP\IUser; +use OCP\IUserManager; +use OCP\IUserSession; class CommentsNodeTest extends \Test\TestCase { @@ -43,19 +48,19 @@ class CommentsNodeTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->comment = $this->getMockBuilder('\OCP\Comments\IComment') + $this->comment = $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); @@ -69,7 +74,7 @@ class CommentsNodeTest extends \Test\TestCase { } public function testDelete() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -104,7 +109,7 @@ class CommentsNodeTest extends \Test\TestCase { * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteForbidden() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -156,7 +161,7 @@ class CommentsNodeTest extends \Test\TestCase { public function testUpdateComment() { $msg = 'Hello Earth'; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -188,13 +193,13 @@ class CommentsNodeTest extends \Test\TestCase { } /** - * @expectedException Exception + * @expectedException \Exception * @expectedExceptionMessage buh! */ public function testUpdateCommentLogException() { $msg = null; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -233,7 +238,7 @@ class CommentsNodeTest extends \Test\TestCase { * @expectedExceptionMessage Message exceeds allowed character limit of */ public function testUpdateCommentMessageTooLongException() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -273,7 +278,7 @@ class CommentsNodeTest extends \Test\TestCase { public function testUpdateForbiddenByUser() { $msg = 'HaXX0r'; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -308,7 +313,7 @@ class CommentsNodeTest extends \Test\TestCase { public function testUpdateForbiddenByType() { $msg = 'HaXX0r'; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -461,7 +466,7 @@ class CommentsNodeTest extends \Test\TestCase { ->method('getObjectId') ->will($this->returnValue($expected[$ns . 'objectId'])); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) @@ -515,7 +520,7 @@ class CommentsNodeTest extends \Test\TestCase { $this->userSession->expects($this->once()) ->method('getUser') ->will($this->returnValue( - $this->getMockBuilder('\OCP\IUser') + $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock() )); diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php index 265afad96c3..e0f7a09a502 100644 --- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php +++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php @@ -27,19 +27,27 @@ namespace OCA\DAV\Tests\unit\Comments; use OC\Comments\Comment; use OCA\DAV\Comments\CommentsPlugin as CommentsPluginImplementation; +use OCA\DAV\Comments\EntityCollection; use OCP\Comments\IComment; +use OCP\Comments\ICommentsManager; +use OCP\IUser; +use OCP\IUserSession; +use Sabre\DAV\INode; +use Sabre\DAV\Tree; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class CommentsPluginTest extends \Test\TestCase { /** @var \Sabre\DAV\Server */ private $server; - /** @var \Sabre\DAV\Tree */ + /** @var Tree */ private $tree; - /** @var \OCP\Comments\ICommentsManager */ + /** @var ICommentsManager */ private $commentsManager; - /** @var \OCP\IUserSession */ + /** @var IUserSession */ private $userSession; /** @var CommentsPluginImplementation */ @@ -47,7 +55,7 @@ class CommentsPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); @@ -56,10 +64,10 @@ class CommentsPluginTest extends \Test\TestCase { ->setMethods(['getRequestUri']) ->getMock(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); @@ -85,14 +93,14 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('alice')); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -124,11 +132,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -181,13 +189,13 @@ class CommentsPluginTest extends \Test\TestCase { $path = 'comments/files/666'; - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->never()) ->method('getUID'); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->never()) @@ -210,11 +218,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->throwException(new \Sabre\DAV\Exception\NotFound())); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -265,13 +273,13 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->never()) ->method('getUID'); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -296,11 +304,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -353,13 +361,13 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->never()) ->method('getUID'); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -384,11 +392,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -443,14 +451,14 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('alice')); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -478,11 +486,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -537,14 +545,14 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('alice')); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -575,11 +583,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -617,7 +625,7 @@ class CommentsPluginTest extends \Test\TestCase { ->method('getNodeForPath') ->with('/' . $path) ->will($this->returnValue( - $this->getMockBuilder('\Sabre\DAV\INode') + $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock() )); @@ -640,7 +648,7 @@ class CommentsPluginTest extends \Test\TestCase { ->method('getNodeForPath') ->with('/' . $path) ->will($this->returnValue( - $this->getMockBuilder('\Sabre\DAV\INode') + $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock() )); @@ -671,7 +679,7 @@ class CommentsPluginTest extends \Test\TestCase { ] ]; - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -679,7 +687,7 @@ class CommentsPluginTest extends \Test\TestCase { ->with(5, 10, null) ->will($this->returnValue([])); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -726,7 +734,7 @@ class CommentsPluginTest extends \Test\TestCase { ] ]; - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -734,7 +742,7 @@ class CommentsPluginTest extends \Test\TestCase { ->with(5, 10, new \DateTime($parameters[2]['value'])) ->will($this->returnValue([])); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php index c4e343d49d4..0cac135843b 100644 --- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php @@ -24,32 +24,39 @@ namespace OCA\DAV\Tests\unit\Comments; +use OCA\DAV\Comments\EntityCollection; +use OCP\Comments\IComment; +use OCP\Comments\ICommentsManager; +use OCP\ILogger; +use OCP\IUserManager; +use OCP\IUserSession; + class EntityCollectionTest extends \Test\TestCase { /** @var \OCP\Comments\ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */ protected $commentsManager; - /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ protected $userManager; - /** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ protected $logger; - /** @var \OCA\DAV\Comments\EntityCollection */ + /** @var EntityCollection */ protected $collection; - /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ protected $userSession; public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); @@ -72,7 +79,7 @@ class EntityCollectionTest extends \Test\TestCase { ->method('get') ->with('55') ->will($this->returnValue( - $this->getMockBuilder('\OCP\Comments\IComment') + $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock() )); @@ -98,7 +105,7 @@ class EntityCollectionTest extends \Test\TestCase { ->method('getForObject') ->with('files', '19') ->will($this->returnValue([ - $this->getMockBuilder('\OCP\Comments\IComment') + $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock() ])); @@ -115,7 +122,7 @@ class EntityCollectionTest extends \Test\TestCase { ->method('getForObject') ->with('files', '19', 5, 15, $dt) ->will($this->returnValue([ - $this->getMockBuilder('\OCP\Comments\IComment') + $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock() ])); diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php index 17c4f70fa7f..c63d95ad533 100644 --- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php @@ -25,10 +25,14 @@ namespace OCA\DAV\Tests\unit\Comments; use OCA\DAV\Comments\EntityCollection as EntityCollectionImplemantation; +use OCP\Comments\ICommentsManager; +use OCP\ILogger; +use OCP\IUserManager; +use OCP\IUserSession; class EntityTypeCollectionTest extends \Test\TestCase { - /** @var \OCP\Comments\ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */ protected $commentsManager; /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ protected $userManager; @@ -36,7 +40,7 @@ class EntityTypeCollectionTest extends \Test\TestCase { protected $logger; /** @var \OCA\DAV\Comments\EntityTypeCollection */ protected $collection; - /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ protected $userSession; protected $childMap = []; @@ -44,16 +48,16 @@ class EntityTypeCollectionTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php index 95afc42a912..05fb94239b4 100644 --- a/apps/dav/tests/unit/Comments/RootCollectionTest.php +++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php @@ -26,6 +26,11 @@ namespace OCA\DAV\Tests\unit\Comments; use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation; use OCP\Comments\CommentsEntityEvent; +use OCP\Comments\ICommentsManager; +use OCP\ILogger; +use OCP\IUser; +use OCP\IUserManager; +use OCP\IUserSession; use Symfony\Component\EventDispatcher\EventDispatcher; class RootCollectionTest extends \Test\TestCase { @@ -48,21 +53,21 @@ class RootCollectionTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); $this->dispatcher = new EventDispatcher(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); |