summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-09-03 15:24:33 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-09-08 09:01:02 +0200
commit190d2c3d5bd8b2bbd39f9112c5b977d27ee70664 (patch)
treebcc74d3313594230ea9a75bc35ee7052b3b6032f /lib
parent270b0bd91b9ff5ab8fa87bd2e8124ff0bb35470b (diff)
downloadnextcloud-server-190d2c3d5bd8b2bbd39f9112c5b977d27ee70664.tar.gz
nextcloud-server-190d2c3d5bd8b2bbd39f9112c5b977d27ee70664.zip
Add tests for the notification manager
Diffstat (limited to 'lib')
-rw-r--r--lib/private/notification/manager.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/private/notification/manager.php b/lib/private/notification/manager.php
index 933c6199bc5..bafb123f768 100644
--- a/lib/private/notification/manager.php
+++ b/lib/private/notification/manager.php
@@ -40,6 +40,13 @@ class Manager implements IManager {
/** @var \Closure */
protected $notifiersClosures;
+ public function __construct() {
+ $this->apps = [];
+ $this->notifiers = [];
+ $this->appsClosures = [];
+ $this->notifiersClosures = [];
+ }
+
/**
* @param \Closure $service The service must implement IApp, otherwise a
* \InvalidArgumentException is thrown later
@@ -70,6 +77,7 @@ class Manager implements IManager {
return $this->apps;
}
+ $this->apps = [];
foreach ($this->appsClosures as $closure) {
$app = $closure();
if (!($app instanceof IApp)) {
@@ -89,6 +97,7 @@ class Manager implements IManager {
return $this->notifiers;
}
+ $this->notifiers = [];
foreach ($this->notifiersClosures as $closure) {
$notifier = $closure();
if (!($notifier instanceof INotifier)) {
@@ -146,11 +155,15 @@ class Manager implements IManager {
continue;
}
- if (!$notification->isValidParsed()) {
+ if (!($notification instanceof INotification) || !$notification->isValidParsed()) {
throw new \InvalidArgumentException('The given notification has not been handled');
}
}
+ if (!($notification instanceof INotification) || !$notification->isValidParsed()) {
+ throw new \InvalidArgumentException('The given notification has not been handled');
+ }
+
return $notification;
}
@@ -175,7 +188,7 @@ class Manager implements IManager {
$count = 0;
foreach ($apps as $app) {
- $count += $app->markProcessed($notification);
+ $count += $app->getCount($notification);
}
return $count;