aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Comments/CommentsPluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Comments/CommentsPluginTest.php')
-rw-r--r--apps/dav/tests/unit/Comments/CommentsPluginTest.php99
1 files changed, 33 insertions, 66 deletions
diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
index 5d05b278e18..18d32772f7b 100644
--- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
@@ -1,28 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\DAV\Tests\unit\Comments;
@@ -33,49 +14,35 @@ use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\IUser;
use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
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 Tree */
- private $tree;
-
- /** @var ICommentsManager */
- private $commentsManager;
-
- /** @var IUserSession */
- private $userSession;
-
- /** @var CommentsPluginImplementation */
- private $plugin;
+ private \Sabre\DAV\Server&MockObject $server;
+ private Tree&MockObject $tree;
+ private ICommentsManager&MockObject $commentsManager;
+ private IUserSession&MockObject $userSession;
+ private CommentsPluginImplementation $plugin;
protected function setUp(): void {
parent::setUp();
- $this->tree = $this->getMockBuilder(Tree::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->tree = $this->createMock(Tree::class);
- $this->server = $this->getMockBuilder('\Sabre\DAV\Server')
+ $this->server = $this->getMockBuilder(\Sabre\DAV\Server::class)
->setConstructorArgs([$this->tree])
- ->setMethods(['getRequestUri'])
+ ->onlyMethods(['getRequestUri'])
->getMock();
- $this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->userSession = $this->getMockBuilder(IUserSession::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->commentsManager = $this->createMock(ICommentsManager::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->plugin = new CommentsPluginImplementation($this->commentsManager, $this->userSession);
}
- public function testCreateComment() {
+ public function testCreateComment(): void {
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -170,8 +137,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
-
- public function testCreateCommentInvalidObject() {
+
+ public function testCreateCommentInvalidObject(): void {
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
$commentData = [
@@ -217,7 +184,7 @@ class CommentsPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->throwException(new \Sabre\DAV\Exception\NotFound()));
+ ->willThrowException(new \Sabre\DAV\Exception\NotFound());
$request = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
@@ -252,8 +219,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
-
- public function testCreateCommentInvalidActor() {
+
+ public function testCreateCommentInvalidActor(): void {
$this->expectException(\Sabre\DAV\Exception\BadRequest::class);
$commentData = [
@@ -340,8 +307,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
-
- public function testCreateCommentUnsupportedMediaType() {
+
+ public function testCreateCommentUnsupportedMediaType(): void {
$this->expectException(\Sabre\DAV\Exception\UnsupportedMediaType::class);
$commentData = [
@@ -428,8 +395,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
-
- public function testCreateCommentInvalidPayload() {
+
+ public function testCreateCommentInvalidPayload(): void {
$this->expectException(\Sabre\DAV\Exception\BadRequest::class);
$commentData = [
@@ -522,8 +489,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
-
- public function testCreateCommentMessageTooLong() {
+
+ public function testCreateCommentMessageTooLong(): void {
$this->expectException(\Sabre\DAV\Exception\BadRequest::class);
$this->expectExceptionMessage('Message exceeds allowed character limit of');
@@ -616,8 +583,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
-
- public function testOnReportInvalidNode() {
+
+ public function testOnReportInvalidNode(): void {
$this->expectException(\Sabre\DAV\Exception\ReportNotSupported::class);
$path = 'totally/unrelated/13';
@@ -639,8 +606,8 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, [], '/' . $path);
}
-
- public function testOnReportInvalidReportName() {
+
+ public function testOnReportInvalidReportName(): void {
$this->expectException(\Sabre\DAV\Exception\ReportNotSupported::class);
$path = 'comments/files/42';
@@ -662,7 +629,7 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->onReport('{whoever}whatever', [], '/' . $path);
}
- public function testOnReportDateTimeEmpty() {
+ public function testOnReportDateTimeEmpty(): void {
$path = 'comments/files/42';
$parameters = [
@@ -717,7 +684,7 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
}
- public function testOnReport() {
+ public function testOnReport(): void {
$path = 'comments/files/42';
$parameters = [