Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OCA\Forms\Db\FormMapper;
use OCA\Forms\Service\CirclesService;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IProvider;
Expand Down Expand Up @@ -44,12 +45,12 @@ public function __construct(
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
* @throws \InvalidArgumentException
* @throws UnknownActivityException
*/
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
// Throw Exception, if not our activity. Necessary for workflow of Activity-App.
if ($event->getApp() !== $this->appName) {
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}
$l10n = $this->l10nFactory->get($this->appName, $language);

Expand All @@ -72,7 +73,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null):
* Provide the translated string with placeholders
* @param $subject The events subject
* @return string
* @throws \InvalidArgumentException
* @throws UnknownActivityException
*/
public function getSubjectString(IL10N $l10n, string $subject): string {
switch ($subject) {
Expand All @@ -90,7 +91,7 @@ public function getSubjectString(IL10N $l10n, string $subject): string {

default:
$this->logger->warning('Some unknown activity has been found: ' . $subject);
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/Activity/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\Forms\Db\Form;
use OCA\Forms\Db\FormMapper;
use OCA\Forms\Service\CirclesService;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\AppFramework\Db\DoesNotExistException;
Expand Down Expand Up @@ -113,7 +114,7 @@ public function testWrongApp() {
->method('getApp')
->willReturn('someOtherApp');

$this->expectException(\InvalidArgumentException::class);
$this->expectException(UnknownActivityException::class);
$this->provider->parse('de_DE', $event);
}

Expand Down Expand Up @@ -220,7 +221,7 @@ public function testGetUnknownSubjectString() {
$l10n->expects($this->never())
->method('t');

$this->expectException(\InvalidArgumentException::class);
$this->expectException(UnknownActivityException::class);
$this->provider->getSubjectString($l10n, 'someUnknownSubject');
}

Expand Down
Loading