summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Comments
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
commit3a7cf40aaa678bea1df143d2982d603b7a334eec (patch)
tree63c1e3ad7f7f401d14411a4d44c523632906afc9 /apps/dav/tests/unit/Comments
parent0568b012672d650c6b5a49e72c4028dde5463c60 (diff)
downloadnextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz
nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/tests/unit/Comments')
-rw-r--r--apps/dav/tests/unit/Comments/CommentsNodeTest.php48
-rw-r--r--apps/dav/tests/unit/Comments/CommentsPluginTest.php46
-rw-r--r--apps/dav/tests/unit/Comments/EntityCollectionTest.php8
-rw-r--r--apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php14
-rw-r--r--apps/dav/tests/unit/Comments/RootCollectionTest.php50
5 files changed, 83 insertions, 83 deletions
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
index 3c230ccfd43..b709fd01e01 100644
--- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
@@ -47,7 +47,7 @@ class CommentsNodeTest extends \Test\TestCase {
protected $logger;
protected $userSession;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
@@ -107,10 +107,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteForbidden() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -149,10 +149,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->assertSame($this->node->getName(), $id);
}
- /**
- * @expectedException \Sabre\DAV\Exception\MethodNotAllowed
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
+
$this->node->setName('666');
}
@@ -194,11 +194,11 @@ class CommentsNodeTest extends \Test\TestCase {
$this->assertTrue($this->node->updateComment($msg));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage buh!
- */
+
public function testUpdateCommentLogException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('buh!');
+
$msg = null;
$user = $this->getMockBuilder(IUser::class)
@@ -235,11 +235,11 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment($msg);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- * @expectedExceptionMessage Message exceeds allowed character limit of
- */
+
public function testUpdateCommentMessageTooLongException() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+ $this->expectExceptionMessage('Message exceeds allowed character limit of');
+
$user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -274,10 +274,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment('foo');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdateForbiddenByUser() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$msg = 'HaXX0r';
$user = $this->getMockBuilder(IUser::class)
@@ -309,10 +309,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment($msg);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdateForbiddenByType() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$msg = 'HaXX0r';
$user = $this->getMockBuilder(IUser::class)
@@ -339,10 +339,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment($msg);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdateForbiddenByNotLoggedIn() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$msg = 'HaXX0r';
$this->userSession->expects($this->once())
diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
index 537989d9404..6cf23d1d42e 100644
--- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
@@ -54,7 +54,7 @@ class CommentsPluginTest extends \Test\TestCase {
/** @var CommentsPluginImplementation */
private $plugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->tree = $this->getMockBuilder(Tree::class)
->disableOriginalConstructor()
@@ -170,10 +170,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testCreateCommentInvalidObject() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -252,10 +252,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testCreateCommentInvalidActor() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$commentData = [
'actorType' => 'robots',
'verb' => 'comment',
@@ -340,10 +340,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\UnsupportedMediaType
- */
+
public function testCreateCommentUnsupportedMediaType() {
+ $this->expectException(\Sabre\DAV\Exception\UnsupportedMediaType::class);
+
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -428,10 +428,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testCreateCommentInvalidPayload() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$commentData = [
'actorType' => 'users',
'verb' => '',
@@ -522,11 +522,11 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- * @expectedExceptionMessage Message exceeds allowed character limit of
- */
+
public function testCreateCommentMessageTooLong() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+ $this->expectExceptionMessage('Message exceeds allowed character limit of');
+
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -616,10 +616,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\ReportNotSupported
- */
+
public function testOnReportInvalidNode() {
+ $this->expectException(\Sabre\DAV\Exception\ReportNotSupported::class);
+
$path = 'totally/unrelated/13';
$this->tree->expects($this->any())
@@ -639,10 +639,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, [], '/' . $path);
}
- /**
- * @expectedException \Sabre\DAV\Exception\ReportNotSupported
- */
+
public function testOnReportInvalidReportName() {
+ $this->expectException(\Sabre\DAV\Exception\ReportNotSupported::class);
+
$path = 'comments/files/42';
$this->tree->expects($this->any())
diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
index 2097c7ef03a..bb3992401f2 100644
--- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
@@ -45,7 +45,7 @@ class EntityCollectionTest extends \Test\TestCase {
/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
protected $userSession;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
@@ -89,10 +89,10 @@ class EntityCollectionTest extends \Test\TestCase {
$this->assertTrue($node instanceof \OCA\DAV\Comments\CommentNode);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildException() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->commentsManager->expects($this->once())
->method('get')
->with('55')
diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
index 9286b46d2b0..038dea82fee 100644
--- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
@@ -46,7 +46,7 @@ class EntityTypeCollectionTest extends \Test\TestCase {
protected $childMap = [];
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
@@ -92,17 +92,17 @@ class EntityTypeCollectionTest extends \Test\TestCase {
$this->assertTrue($ec instanceof EntityCollectionImplemantation);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildException() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->collection->getChild('17');
}
- /**
- * @expectedException \Sabre\DAV\Exception\MethodNotAllowed
- */
+
public function testGetChildren() {
+ $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
+
$this->collection->getChildren();
}
}
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php
index a0e72bcd425..cee5afc0eb3 100644
--- a/apps/dav/tests/unit/Comments/RootCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php
@@ -53,7 +53,7 @@ class RootCollectionTest extends \Test\TestCase {
/** @var \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject */
protected $user;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->getMockBuilder(IUser::class)
@@ -106,17 +106,17 @@ class RootCollectionTest extends \Test\TestCase {
});
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testCreateFile() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->createFile('foo');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testCreateDirectory() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->createDirectory('foo');
}
@@ -126,18 +126,18 @@ class RootCollectionTest extends \Test\TestCase {
$this->assertTrue($etc instanceof EntityTypeCollectionImplementation);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildInvalid() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->prepareForInitCollections();
$this->collection->getChild('robots');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- */
+
public function testGetChildNoAuth() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+
$this->collection->getChild('files');
}
@@ -150,10 +150,10 @@ class RootCollectionTest extends \Test\TestCase {
}
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- */
+
public function testGetChildrenNoAuth() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+
$this->collection->getChildren();
}
@@ -167,17 +167,17 @@ class RootCollectionTest extends \Test\TestCase {
$this->assertFalse($this->collection->childExists('robots'));
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- */
+
public function testChildExistsNoAuth() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+
$this->collection->childExists('files');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDelete() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->delete();
}
@@ -185,10 +185,10 @@ class RootCollectionTest extends \Test\TestCase {
$this->assertSame('comments', $this->collection->getName());
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->setName('foobar');
}