Skip to content

Commit 1667c64

Browse files
CarlSchwanbackportbot[bot]
authored andcommitted
fix(tests): Adapt tests for comments
And make sure these are now covered by psalm Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent 8121f29 commit 1667c64

8 files changed

Lines changed: 38 additions & 6 deletions

File tree

apps/comments/tests/Unit/Activity/ListenerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ListenerTest extends TestCase {
3535
protected IShareHelper&MockObject $shareHelper;
3636
protected Listener $listener;
3737

38+
#[\Override]
3839
protected function setUp(): void {
3940
parent::setUp();
4041

apps/comments/tests/Unit/AppInfo/ApplicationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
*/
2929
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
3030
class ApplicationTest extends TestCase {
31+
#[\Override]
3132
protected function setUp(): void {
3233
parent::setUp();
3334
Server::get(IUserManager::class)->createUser('dummy', '456');
3435
Server::get(IUserSession::class)->setUser(Server::get(IUserManager::class)->get('dummy'));
3536
}
3637

38+
#[\Override]
3739
protected function tearDown(): void {
3840
Server::get(IUserManager::class)->get('dummy')->delete();
3941
parent::tearDown();

apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class CommentersSorterTest extends TestCase {
1616
protected ICommentsManager&MockObject $commentsManager;
1717
protected CommentersSorter $sorter;
1818

19+
#[\Override]
1920
protected function setUp(): void {
2021
parent::setUp();
2122

apps/comments/tests/Unit/Controller/NotificationsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class NotificationsTest extends TestCase {
3535
protected IURLGenerator&MockObject $urlGenerator;
3636
protected NotificationsController $notificationsController;
3737

38+
#[\Override]
3839
protected function setUp(): void {
3940
parent::setUp();
4041

apps/comments/tests/Unit/EventHandlerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use OCP\Comments\Events\CommentDeletedEvent;
1818
use OCP\Comments\Events\CommentUpdatedEvent;
1919
use OCP\Comments\IComment;
20+
use OCP\EventDispatcher\IEventDispatcher;
21+
use PHPUnit\Framework\Attributes\DataProvider;
2022
use PHPUnit\Framework\MockObject\MockObject;
2123
use Test\TestCase;
2224

@@ -25,23 +27,22 @@ class EventHandlerTest extends TestCase {
2527
protected NotificationListener&MockObject $notificationListener;
2628
protected CommentsEventListener $eventHandler;
2729

30+
#[\Override]
2831
protected function setUp(): void {
2932
parent::setUp();
3033

3134
$this->activityListener = $this->createMock(ActivityListener::class);
3235
$this->notificationListener = $this->createMock(NotificationListener::class);
3336

34-
$this->eventHandler = new CommentsEventListener($this->activityListener, $this->notificationListener);
37+
$this->eventHandler = new CommentsEventListener($this->activityListener, $this->notificationListener, $this->createMock(IEventDispatcher::class));
3538
}
3639

3740
public function testNotFiles(): void {
38-
/** @var IComment|MockObject $comment */
3941
$comment = $this->createMock(IComment::class);
4042
$comment->expects($this->once())
4143
->method('getObjectType')
4244
->willReturn('smiles');
4345

44-
/** @var CommentsEvent|MockObject $event */
4546
$event = $this->createMock(CommentsEvent::class);
4647
$event->expects($this->once())
4748
->method('getComment')
@@ -61,9 +62,8 @@ public static function handledProvider(): array {
6162
];
6263
}
6364

64-
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'handledProvider')]
65+
#[DataProvider(methodName: 'handledProvider')]
6566
public function testHandled(string $eventType): void {
66-
/** @var IComment|MockObject $comment */
6767
$comment = $this->createMock(IComment::class);
6868
$comment->expects($this->once())
6969
->method('getObjectType')

apps/comments/tests/Unit/Notification/ListenerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ListenerTest extends TestCase {
2626
protected IURLGenerator&MockObject $urlGenerator;
2727
protected Listener $listener;
2828

29+
#[\Override]
2930
protected function setUp(): void {
3031
parent::setUp();
3132

apps/comments/tests/Unit/Notification/NotifierTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class NotifierTest extends TestCase {
3737
protected Notifier $notifier;
3838
protected string $lc = 'tlh_KX';
3939

40+
#[\Override]
4041
protected function setUp(): void {
4142
parent::setUp();
4243

psalm.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,32 @@
6464
<file name="version.php"/>
6565
<file name="tests/lib/TestCase.php"/>
6666
<ignoreFiles>
67-
<directory name="apps/**/tests"/>
67+
<directory name="apps/admin_audit/tests"/>
68+
<directory name="apps/cloud_federation_api/tests"/>
69+
<directory name="apps/contactsinteraction/tests"/>
70+
<directory name="apps/dashboard/tests"/>
71+
<directory name="apps/dav/tests"/>
72+
<directory name="apps/encryption/tests"/>
73+
<directory name="apps/federatedfilesharing/tests"/>
74+
<directory name="apps/federation/tests"/>
75+
<directory name="apps/files/tests"/>
76+
<directory name="apps/files_external/tests"/>
77+
<directory name="apps/files_sharing/tests"/>
78+
<directory name="apps/files_trashbin/tests"/>
79+
<directory name="apps/files_versions/tests"/>
80+
<directory name="apps/oauth2/tests"/>
81+
<directory name="apps/profile/tests"/>
82+
<directory name="apps/provisioning_api/tests"/>
83+
<directory name="apps/settings/tests"/>
84+
<directory name="apps/sharebymail/tests"/>
85+
<directory name="apps/systemtags/tests"/>
86+
<directory name="apps/theming/tests"/>
87+
<directory name="apps/twofactor_backupcodes/tests"/>
88+
<directory name="apps/updatenotification/tests"/>
89+
<directory name="apps/user_ldap/tests"/>
90+
<directory name="apps/user_status/tests"/>
91+
<directory name="apps/webhook_listeners/tests"/>
92+
<directory name="apps/workflowengine/tests"/>
6893
<directory name="apps/**/composer"/>
6994
<directory name="lib/composer"/>
7095
<directory name="lib/l10n"/>

0 commit comments

Comments
 (0)