diff options
Diffstat (limited to 'tests/lib/Comments/CommentTest.php')
-rw-r--r-- | tests/lib/Comments/CommentTest.php | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index 3cfc897b28e..4a320666c83 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/tests/lib/Comments/CommentTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -8,11 +9,13 @@ namespace Test\Comments; use OC\Comments\Comment; use OCP\Comments\IComment; +use OCP\Comments\IllegalIDChangeException; +use OCP\Comments\MessageTooLongException; use Test\TestCase; class CommentTest extends TestCase { /** - * @throws \OCP\Comments\IllegalIDChangeException + * @throws IllegalIDChangeException */ public function testSettersValidInput(): void { $comment = new Comment(); @@ -62,7 +65,7 @@ class CommentTest extends TestCase { public function testSetIdIllegalInput(): void { - $this->expectException(\OCP\Comments\IllegalIDChangeException::class); + $this->expectException(IllegalIDChangeException::class); $comment = new Comment(); @@ -71,7 +74,7 @@ class CommentTest extends TestCase { } /** - * @throws \OCP\Comments\IllegalIDChangeException + * @throws IllegalIDChangeException */ public function testResetId(): void { $comment = new Comment(); @@ -81,7 +84,7 @@ class CommentTest extends TestCase { $this->assertSame('', $comment->getId()); } - public function simpleSetterProvider() { + public static function simpleSetterProvider(): array { return [ ['Id', true], ['TopmostParentId', true], @@ -93,9 +96,7 @@ class CommentTest extends TestCase { ]; } - /** - * @dataProvider simpleSetterProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('simpleSetterProvider')] public function testSimpleSetterInvalidInput($field, $input): void { $this->expectException(\InvalidArgumentException::class); @@ -105,7 +106,7 @@ class CommentTest extends TestCase { $comment->$setter($input); } - public function roleSetterProvider() { + public static function roleSetterProvider(): array { return [ ['Actor', true, true], ['Actor', 'users', true], @@ -118,9 +119,7 @@ class CommentTest extends TestCase { ]; } - /** - * @dataProvider roleSetterProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('roleSetterProvider')] public function testSetRoleInvalidInput($role, $type, $id): void { $this->expectException(\InvalidArgumentException::class); @@ -131,14 +130,14 @@ class CommentTest extends TestCase { public function testSetUberlongMessage(): void { - $this->expectException(\OCP\Comments\MessageTooLongException::class); + $this->expectException(MessageTooLongException::class); $comment = new Comment(); $msg = str_pad('', IComment::MAX_MESSAGE_LENGTH + 1, 'x'); $comment->setMessage($msg); } - public function mentionsProvider(): array { + public static function mentionsProvider(): array { return [ [ '@alice @bob look look, a cook!', @@ -158,11 +157,11 @@ class CommentTest extends TestCase { /* author: */ 'alice' ], [ - '@foobar and @barfoo you should know, @foo@bar.com is valid' . - ' and so is @bar@foo.org@foobar.io I hope that clarifies everything.' . - ' cc @23452-4333-54353-2342 @yolo!' . - ' however the most important thing to know is that www.croissant.com/@oil is not valid' . - ' and won\'t match anything at all', + '@foobar and @barfoo you should know, @foo@bar.com is valid' + . ' and so is @bar@foo.org@foobar.io I hope that clarifies everything.' + . ' cc @23452-4333-54353-2342 @yolo!' + . ' however the most important thing to know is that www.croissant.com/@oil is not valid' + . ' and won\'t match anything at all', [ ['type' => 'user', 'id' => 'bar@foo.org@foobar.io'], ['type' => 'user', 'id' => '23452-4333-54353-2342'], @@ -206,12 +205,12 @@ class CommentTest extends TestCase { } /** - * @dataProvider mentionsProvider * * @param string $message * @param array $expectedMentions * @param ?string $author */ + #[\PHPUnit\Framework\Attributes\DataProvider('mentionsProvider')] public function testMentions(string $message, array $expectedMentions, ?string $author = null): void { $comment = new Comment(); $comment->setMessage($message); |