Skip to content

Commit dc58f80

Browse files
committed
test: Remove debug logs triggered by the testing app
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent b8553be commit dc58f80

5 files changed

Lines changed: 25 additions & 58 deletions

File tree

tests/Integration/app/appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
<repository>https://github.com/nextcloud/notifications.git</repository>
2828

2929
<dependencies>
30-
<nextcloud min-version="28" max-version="28" />
30+
<nextcloud min-version="32" max-version="32" />
3131
</dependencies>
3232
</info>

tests/Integration/app/appinfo/routes.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/Integration/app/lib/AppInfo/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44
/**
55
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
6-
* SPDX-License-Identifier: AGPL-3.0-only
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
77
*/
88

99
namespace OCA\NotificationsIntegrationTesting\AppInfo;

tests/Integration/app/lib/Controller/EndpointController.php

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,50 @@
11
<?php
2+
3+
declare(strict_types=1);
24
/**
5+
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
36
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
47
* SPDX-License-Identifier: AGPL-3.0-only
58
*/
69

710
namespace OCA\NotificationsIntegrationTesting\Controller;
811

12+
use OCP\AppFramework\Http\Attribute\ApiRoute;
13+
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
914
use OCP\AppFramework\Http\DataResponse;
1015
use OCP\AppFramework\OCSController;
1116
use OCP\IRequest;
1217
use OCP\Notification\IManager;
1318

1419
class EndpointController extends OCSController {
15-
/** @var IManager */
16-
private $manager;
17-
18-
/**
19-
* @param string $appName
20-
* @param IRequest $request
21-
* @param IManager $manager
22-
*/
23-
public function __construct($appName, IRequest $request, IManager $manager) {
20+
public function __construct(
21+
string $appName,
22+
IRequest $request,
23+
protected IManager $manager,
24+
) {
2425
parent::__construct($appName, $request);
25-
$this->manager = $manager;
2626
}
2727

28-
/**
29-
* @NoCSRFRequired
30-
*
31-
* @param string $userId
32-
* @return DataResponse
33-
*/
34-
public function addNotification(string $userId = 'test1') {
28+
#[NoCSRFRequired]
29+
#[ApiRoute(verb: 'POST', url: '/notifications')]
30+
public function addNotification(string $userId = 'test1'): DataResponse {
3531
$notification = $this->manager->createNotification();
3632
$notification->setApp($this->request->getParam('app', 'notificationsintegrationtesting'))
37-
->setDateTime(\DateTime::createFromFormat('U', $this->request->getParam('timestamp', 1449585176))) // 2015-12-08T14:32:56+00:00
33+
->setDateTime(\DateTime::createFromFormat('U', (string)$this->request->getParam('timestamp', '1449585176'))) // 2015-12-08T14:32:56+00:00
3834
->setUser($this->request->getParam('user', $userId))
3935
->setSubject($this->request->getParam('subject', 'testing'))
4036
->setLink($this->request->getParam('link', 'https://example.tld/'))
4137
->setMessage($this->request->getParam('message', 'message'))
42-
->setObject($this->request->getParam('object_type', 'object'), $this->request->getParam('object_id', 23));
38+
->setObject($this->request->getParam('object_type', 'object'), (string)$this->request->getParam('object_id', '23'));
4339

4440
$this->manager->notify($notification);
4541

4642
return new DataResponse();
4743
}
4844

49-
/**
50-
* @NoCSRFRequired
51-
*
52-
* @return DataResponse
53-
*/
54-
public function deleteNotifications() {
45+
#[NoCSRFRequired]
46+
#[ApiRoute(verb: 'DELETE', url: '')]
47+
public function deleteNotifications(): DataResponse {
5548
$notification = $this->manager->createNotification();
5649
$this->manager->markProcessed($notification);
5750

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2+
3+
declare(strict_types=1);
24
/**
5+
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
36
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
47
* SPDX-License-Identifier: AGPL-3.0-only
58
*/
@@ -8,41 +11,24 @@
811

912
use OCP\Notification\INotification;
1013
use OCP\Notification\INotifier;
14+
use OCP\Notification\UnknownNotificationException;
1115

1216
class Notifier implements INotifier {
13-
/**
14-
* Identifier of the notifier, only use [a-z0-9_]
15-
*
16-
* @return string
17-
* @since 17.0.0
18-
*/
1917
public function getID(): string {
2018
return 'notificationsintegrationtesting';
2119
}
2220

23-
/**
24-
* Human readable name describing the notifier
25-
*
26-
* @return string
27-
* @since 17.0.0
28-
*/
2921
public function getName(): string {
3022
return 'Integration test';
3123
}
3224

33-
/**
34-
* @param INotification $notification
35-
* @param string $languageCode The code of the language that should be used to prepare the notification
36-
* @return INotification
37-
* @throws \InvalidArgumentException When the notification was not prepared by a notifier
38-
*/
3925
public function prepare(INotification $notification, string $languageCode): INotification {
4026
if ($notification->getApp() === 'notificationsintegrationtesting') {
4127
$notification->setParsedSubject($notification->getSubject());
4228
$notification->setParsedMessage($notification->getMessage());
4329
return $notification;
4430
}
4531

46-
throw new \InvalidArgumentException();
32+
throw new UnknownNotificationException();
4733
}
4834
}

0 commit comments

Comments
 (0)