Add another hierarchy level for decorators to indicate their function.
authorGunnar Wrobel <p@rdus.de>
Wed, 4 Nov 2009 23:02:04 +0000 (00:02 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 4 Nov 2009 23:02:04 +0000 (00:02 +0100)
15 files changed:
framework/Notification/lib/Horde/Notification.php
framework/Notification/lib/Horde/Notification/Handler/Alarm.php [deleted file]
framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php [new file with mode: 0644]
framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php [new file with mode: 0644]
framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php [new file with mode: 0644]
framework/Notification/lib/Horde/Notification/Handler/Hordelog.php [deleted file]
framework/Notification/lib/Horde/Notification/Handler/Logged.php [deleted file]
framework/Notification/package.xml
framework/Notification/test/Horde/Notification/Class/Notification/Handler/AlarmTest.php [deleted file]
framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php [new file with mode: 0644]
framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php [new file with mode: 0644]
framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php [new file with mode: 0644]
framework/Notification/test/Horde/Notification/Class/Notification/Handler/HordelogTest.php [deleted file]
framework/Notification/test/Horde/Notification/Class/Notification/Handler/LoggedTest.php [deleted file]
framework/Notification/test/Horde/Notification/Class/NotificationTest.php

index 07e2d1c..e1f582f 100644 (file)
@@ -38,9 +38,9 @@ class Horde_Notification
             $storage = new Horde_Notification_Storage_Session($stack);
 
             $handler = new Horde_Notification_Handler_Base($storage);
-            $handler = new Horde_Notification_Handler_Hordelog($handler);
+            $handler = new Horde_Notification_Handler_Decorator_Hordelog($handler);
             if (!empty($GLOBALS['conf']['alarms']['driver'])) {
-                $handler = new Horde_Notification_Handler_Alarm(
+                $handler = new Horde_Notification_Handler_Decorator_Alarm(
                     $handler, Horde_Alarm::factory()
                 );
             }
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Alarm.php b/framework/Notification/lib/Horde/Notification/Handler/Alarm.php
deleted file mode 100644 (file)
index 4b4e43d..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-/**
- * The Horde_Notification_Handler_Alarm notifies the alarm system if required.
- *
- * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jan Schneider <jan@horde.org>
- * @package Horde_Notification
- */
-class Horde_Notification_Handler_Alarm
-implements Horde_Notification_Handler_Interface
-{
-    /**
-     * The notification handler decorated by this instance.
-     *
-     * @var Horde_Notification_Handler
-     */
-    private $_handler;
-
-    /**
-     * A Horde_Alarm instance.
-     *
-     * @var Horde_Alarm
-     */
-    protected $_alarm;
-
-    /**
-     * Initialize the notification system, set up any needed session
-     * variables, etc.
-     *
-     * @param Horde_Notification_Handler $handler The handler this instance
-     *                                            provides with logging.
-     * @param Horde_Alarm                $alarm   The alarm system to notify.
-     */
-    public function __construct(
-        Horde_Notification_Handler_Interface $handler,
-        Horde_Alarm $alarm
-    ) {
-        $this->_handler = $handler;
-        $this->_alarm   = $alarm;
-    }
-
-    /**
-     * Registers a listener with the notification object and includes
-     * the necessary library file dynamically.
-     *
-     * @param string $listener  The name of the listener to attach. These
-     *                          names must be unique; further listeners with
-     *                          the same name will be ignored.
-     * @param array $params     A hash containing any additional configuration
-     *                          or connection parameters a listener driver
-     *                          might need.
-     * @param string $class     The class name from which the driver was
-     *                          instantiated if not the default one. If given
-     *                          you have to include the library file
-     *                          containing this class yourself. This is useful
-     *                          if you want the listener driver to be
-     *                          overriden by an application's implementation.
-     *
-     * @return Horde_Notification_Listener  The listener object.
-     * @throws Horde_Exception
-     */
-    public function attach($listener, $params = null, $class = null)
-    {
-        return $this->_handler->attach($listener, $params, $class);
-    }
-
-    /**
-     * Remove a listener from the notification list. This will discard any
-     * notifications in this listeners stack.
-     *
-     * @param string $listner  The name of the listener to detach.
-     *
-     * @throws Horde_Exception
-     */
-    public function detach($listener)
-    {
-        $this->_handler->detach($listener);
-    }
-
-    /**
-     * Replaces a listener in the notification list. This preserves all
-     * notifications in this listeners stack. If the listener does not exist,
-     * the new listener will be added automatically.
-     *
-     * @param string $listener  See attach().
-     * @param array $params     See attach().
-     * @param string $class     See attach().
-     *
-     * @return Horde_Notification_Listener  See attach()
-     * @throws Horde_Exception
-     */
-    public function replace($listener, array $params = array(), $class = null)
-    {
-        return $this->_handler->replace($listener, $params, $class);
-    }
-
-    /**
-     * Add an event to the Horde message stack.
-     *
-     * The event type parameter should begin with 'horde.' unless the
-     * application defines its own Horde_Notification_Listener subclass that
-     * handles additional codes.
-     *
-     * @param mixed $event   Horde_Notification_Event object or message string.
-     * @param integer $type  The type of message: 'horde.error',
-     *                       'horde.warning', 'horde.success', or
-     *                       'horde.message'.
-     * @param array $flags   Array of optional flags that will be passed to the
-     *                       registered listeners.
-     */
-    public function push($event, $type = null, array $flags = array())
-    {
-        $this->_handler->push($event, $type, $flags);
-    }
-
-    /**
-     * Passes the message stack to all listeners and asks them to
-     * handle their messages.
-     *
-     * @param array $options  An array containing display options for the
-     *                        listeners.
-     */
-    public function notify(array $options = array())
-    {
-        $this->_handler->setNotificationListeners($options);
-
-        if (in_array('status', $options['listeners'])) {
-            $this->_alarm->notify(Horde_Auth::getAuth());
-        }
-
-        $this->_handler->notifyListeners($options);
-    }
-
-    /**
-     * Convert the 'listeners' option into the format expected by the
-     * notification handler.
-     *
-     * @param array $options  An array containing display options for the
-     *                        listeners.
-     */
-    public function setNotificationListeners(array &$options)
-    {
-        $this->_handler->setNotificationListeners($options);
-    }
-
-    /**
-     * Passes the message stack to all listeners and asks them to
-     * handle their messages.
-     *
-     * @param array $options An array containing display options for the
-     *                       listeners. This array is required to contain the
-     *                       correct lowercased listener names as array in the
-     *                       entry 'listeners'.
-     */
-    public function notifyListeners(array $options)
-    {
-        $this->_handler->notifyListeners($options);
-    }
-
-    /**
-     * Return the number of notification messages in the stack.
-     *
-     * @author David Ulevitch <davidu@everydns.net>
-     *
-     * @param string $my_listener  The name of the listener.
-     *
-     * @return integer  The number of messages in the stack.
-     */
-    public function count($my_listener = null)
-    {
-        return $this->_handler->count($my_listener);
-    }
-
-}
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php
new file mode 100644 (file)
index 0000000..26d2e5a
--- /dev/null
@@ -0,0 +1,178 @@
+<?php
+/**
+ * The Horde_Notification_Handler_Alarm notifies the alarm system if required.
+ *
+ * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Jan Schneider <jan@horde.org>
+ * @package Horde_Notification
+ */
+class Horde_Notification_Handler_Decorator_Alarm
+implements Horde_Notification_Handler_Interface
+{
+    /**
+     * The notification handler decorated by this instance.
+     *
+     * @var Horde_Notification_Handler
+     */
+    private $_handler;
+
+    /**
+     * A Horde_Alarm instance.
+     *
+     * @var Horde_Alarm
+     */
+    protected $_alarm;
+
+    /**
+     * Initialize the notification system, set up any needed session
+     * variables, etc.
+     *
+     * @param Horde_Notification_Handler $handler The handler this instance
+     *                                            provides with logging.
+     * @param Horde_Alarm                $alarm   The alarm system to notify.
+     */
+    public function __construct(
+        Horde_Notification_Handler_Interface $handler,
+        Horde_Alarm $alarm
+    ) {
+        $this->_handler = $handler;
+        $this->_alarm   = $alarm;
+    }
+
+    /**
+     * Registers a listener with the notification object and includes
+     * the necessary library file dynamically.
+     *
+     * @param string $listener  The name of the listener to attach. These
+     *                          names must be unique; further listeners with
+     *                          the same name will be ignored.
+     * @param array $params     A hash containing any additional configuration
+     *                          or connection parameters a listener driver
+     *                          might need.
+     * @param string $class     The class name from which the driver was
+     *                          instantiated if not the default one. If given
+     *                          you have to include the library file
+     *                          containing this class yourself. This is useful
+     *                          if you want the listener driver to be
+     *                          overriden by an application's implementation.
+     *
+     * @return Horde_Notification_Listener  The listener object.
+     * @throws Horde_Exception
+     */
+    public function attach($listener, $params = null, $class = null)
+    {
+        return $this->_handler->attach($listener, $params, $class);
+    }
+
+    /**
+     * Remove a listener from the notification list. This will discard any
+     * notifications in this listeners stack.
+     *
+     * @param string $listner  The name of the listener to detach.
+     *
+     * @throws Horde_Exception
+     */
+    public function detach($listener)
+    {
+        $this->_handler->detach($listener);
+    }
+
+    /**
+     * Replaces a listener in the notification list. This preserves all
+     * notifications in this listeners stack. If the listener does not exist,
+     * the new listener will be added automatically.
+     *
+     * @param string $listener  See attach().
+     * @param array $params     See attach().
+     * @param string $class     See attach().
+     *
+     * @return Horde_Notification_Listener  See attach()
+     * @throws Horde_Exception
+     */
+    public function replace($listener, array $params = array(), $class = null)
+    {
+        return $this->_handler->replace($listener, $params, $class);
+    }
+
+    /**
+     * Add an event to the Horde message stack.
+     *
+     * The event type parameter should begin with 'horde.' unless the
+     * application defines its own Horde_Notification_Listener subclass that
+     * handles additional codes.
+     *
+     * @param mixed $event   Horde_Notification_Event object or message string.
+     * @param integer $type  The type of message: 'horde.error',
+     *                       'horde.warning', 'horde.success', or
+     *                       'horde.message'.
+     * @param array $flags   Array of optional flags that will be passed to the
+     *                       registered listeners.
+     */
+    public function push($event, $type = null, array $flags = array())
+    {
+        $this->_handler->push($event, $type, $flags);
+    }
+
+    /**
+     * Passes the message stack to all listeners and asks them to
+     * handle their messages.
+     *
+     * @param array $options  An array containing display options for the
+     *                        listeners.
+     */
+    public function notify(array $options = array())
+    {
+        $this->_handler->setNotificationListeners($options);
+
+        if (in_array('status', $options['listeners'])) {
+            $this->_alarm->notify(Horde_Auth::getAuth());
+        }
+
+        $this->_handler->notifyListeners($options);
+    }
+
+    /**
+     * Convert the 'listeners' option into the format expected by the
+     * notification handler.
+     *
+     * @param array $options  An array containing display options for the
+     *                        listeners.
+     */
+    public function setNotificationListeners(array &$options)
+    {
+        $this->_handler->setNotificationListeners($options);
+    }
+
+    /**
+     * Passes the message stack to all listeners and asks them to
+     * handle their messages.
+     *
+     * @param array $options An array containing display options for the
+     *                       listeners. This array is required to contain the
+     *                       correct lowercased listener names as array in the
+     *                       entry 'listeners'.
+     */
+    public function notifyListeners(array $options)
+    {
+        $this->_handler->notifyListeners($options);
+    }
+
+    /**
+     * Return the number of notification messages in the stack.
+     *
+     * @author David Ulevitch <davidu@everydns.net>
+     *
+     * @param string $my_listener  The name of the listener.
+     *
+     * @return integer  The number of messages in the stack.
+     */
+    public function count($my_listener = null)
+    {
+        return $this->_handler->count($my_listener);
+    }
+
+}
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php
new file mode 100644 (file)
index 0000000..5054f5f
--- /dev/null
@@ -0,0 +1,165 @@
+<?php
+/**
+ * The Horde_Notification_Handler_Hordelog logs error events via
+ * Horde::logMessage().
+ *
+ * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Jan Schneider <jan@horde.org>
+ * @package Horde_Notification
+ */
+class Horde_Notification_Handler_Decorator_Hordelog
+implements Horde_Notification_Handler_Interface
+{
+    /**
+     * The notification handler decorated by this instance.
+     *
+     * @var Horde_Notification_Handler
+     */
+    private $_handler;
+
+    /**
+     * Initialize the notification system, set up any needed session
+     * variables, etc.
+     *
+     * @param Horde_Notification_Handler $handler The handler this instance
+     *                                            provides with logging.
+     */
+    public function __construct(
+        Horde_Notification_Handler_Interface $handler
+    ) {
+        $this->_handler = $handler;
+    }
+
+    /**
+     * Registers a listener with the notification object and includes
+     * the necessary library file dynamically.
+     *
+     * @param string $listener  The name of the listener to attach. These
+     *                          names must be unique; further listeners with
+     *                          the same name will be ignored.
+     * @param array $params     A hash containing any additional configuration
+     *                          or connection parameters a listener driver
+     *                          might need.
+     * @param string $class     The class name from which the driver was
+     *                          instantiated if not the default one. If given
+     *                          you have to include the library file
+     *                          containing this class yourself. This is useful
+     *                          if you want the listener driver to be
+     *                          overriden by an application's implementation.
+     *
+     * @return Horde_Notification_Listener  The listener object.
+     * @throws Horde_Exception
+     */
+    public function attach($listener, $params = null, $class = null)
+    {
+        return $this->_handler->attach($listener, $params, $class);
+    }
+
+    /**
+     * Remove a listener from the notification list. This will discard any
+     * notifications in this listeners stack.
+     *
+     * @param string $listner  The name of the listener to detach.
+     *
+     * @throws Horde_Exception
+     */
+    public function detach($listener)
+    {
+        $this->_handler->detach($listener);
+    }
+
+    /**
+     * Replaces a listener in the notification list. This preserves all
+     * notifications in this listeners stack. If the listener does not exist,
+     * the new listener will be added automatically.
+     *
+     * @param string $listener  See attach().
+     * @param array $params     See attach().
+     * @param string $class     See attach().
+     *
+     * @return Horde_Notification_Listener  See attach()
+     * @throws Horde_Exception
+     */
+    public function replace($listener, array $params = array(), $class = null)
+    {
+        return $this->_handler->replace($listener, $params, $class);
+    }
+
+    /**
+     * Add an event to the Horde message stack.
+     *
+     * The event type parameter should begin with 'horde.' unless the
+     * application defines its own Horde_Notification_Listener subclass that
+     * handles additional codes.
+     *
+     * @param mixed $event   Horde_Notification_Event object or message string.
+     * @param integer $type  The type of message: 'horde.error',
+     *                       'horde.warning', 'horde.success', or
+     *                       'horde.message'.
+     * @param array $flags   Array of optional flags that will be passed to the
+     *                       registered listeners.
+     */
+    public function push($event, $type = null, array $flags = array())
+    {
+        if ($event instanceof PEAR_Error || $event instanceof Exception) {
+            Horde::logMessage($event, __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        }
+        $this->_handler->push($event, $type, $flags);
+    }
+
+    /**
+     * Passes the message stack to all listeners and asks them to
+     * handle their messages.
+     *
+     * @param array $options  An array containing display options for the
+     *                        listeners.
+     */
+    public function notify(array $options = array())
+    {
+        $this->_handler->notify($options);
+    }
+
+    /**
+     * Convert the 'listeners' option into the format expected by the
+     * notification handler.
+     *
+     * @param array $options  An array containing display options for the
+     *                        listeners.
+     */
+    public function setNotificationListeners(array &$options)
+    {
+        $this->_handler->setNotificationListeners($options);
+    }
+
+    /**
+     * Passes the message stack to all listeners and asks them to
+     * handle their messages.
+     *
+     * @param array $options An array containing display options for the
+     *                       listeners. This array is required to contain the
+     *                       correct lowercased listener names as array in the
+     *                       entry 'listeners'.
+     */
+    public function notifyListeners(array $options)
+    {
+        $this->_handler->notifyListeners($options);
+    }
+
+    /**
+     * Return the number of notification messages in the stack.
+     *
+     * @author David Ulevitch <davidu@everydns.net>
+     *
+     * @param string $my_listener  The name of the listener.
+     *
+     * @return integer  The number of messages in the stack.
+     */
+    public function count($my_listener = null)
+    {
+        return $this->_handler->count($my_listener);
+    }
+}
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php
new file mode 100644 (file)
index 0000000..adf7a3c
--- /dev/null
@@ -0,0 +1,186 @@
+<?php
+/**
+ * The Horde_Notification_Handler_Logged logs error events once they are pushed
+ * to the stack.
+ *
+ * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Jan Schneider <jan@horde.org>
+ * @package Horde_Notification
+ */
+class Horde_Notification_Handler_Decorator_Log
+implements Horde_Notification_Handler_Interface
+{
+    /**
+     * The notification handler decorated by this instance.
+     *
+     * @var Horde_Notification_Handler
+     */
+    private $_handler;
+
+    /**
+     * The log handler.
+     *
+     * @var mixed
+     */
+    private $_logger;
+
+    /**
+     * Initialize the notification system, set up any needed session
+     * variables, etc.
+     *
+     * @param Horde_Notification_Handler $handler The handler this instance
+     *                                            provides with logging.
+     *
+     * @param mixed                      $logger  The log handler. The provided
+     *                                            instance is required to
+     *                                            implement the debug() function.
+     *                                            You should be able to use a
+     *                                            common Logger here (PEAR Log,
+     *                                            Horde_Log_Logger, or Zend_Log).
+     */
+    public function __construct(
+        Horde_Notification_Handler_Interface $handler,
+        $logger
+    ) {
+        $this->_handler = $handler;
+        $this->_logger  = $logger;
+    }
+
+    /**
+     * Registers a listener with the notification object and includes
+     * the necessary library file dynamically.
+     *
+     * @param string $listener  The name of the listener to attach. These
+     *                          names must be unique; further listeners with
+     *                          the same name will be ignored.
+     * @param array $params     A hash containing any additional configuration
+     *                          or connection parameters a listener driver
+     *                          might need.
+     * @param string $class     The class name from which the driver was
+     *                          instantiated if not the default one. If given
+     *                          you have to include the library file
+     *                          containing this class yourself. This is useful
+     *                          if you want the listener driver to be
+     *                          overriden by an application's implementation.
+     *
+     * @return Horde_Notification_Listener  The listener object.
+     * @throws Horde_Exception
+     */
+    public function attach($listener, $params = null, $class = null)
+    {
+        return $this->_handler->attach($listener, $params, $class);
+    }
+
+    /**
+     * Remove a listener from the notification list. This will discard any
+     * notifications in this listeners stack.
+     *
+     * @param string $listner  The name of the listener to detach.
+     *
+     * @throws Horde_Exception
+     */
+    public function detach($listener)
+    {
+        $this->_handler->detach($listener);
+    }
+
+    /**
+     * Replaces a listener in the notification list. This preserves all
+     * notifications in this listeners stack. If the listener does not exist,
+     * the new listener will be added automatically.
+     *
+     * @param string $listener  See attach().
+     * @param array $params     See attach().
+     * @param string $class     See attach().
+     *
+     * @return Horde_Notification_Listener  See attach()
+     * @throws Horde_Exception
+     */
+    public function replace($listener, array $params = array(), $class = null)
+    {
+        return $this->_handler->replace($listener, $params, $class);
+    }
+
+    /**
+     * Add an event to the Horde message stack.
+     *
+     * The event type parameter should begin with 'horde.' unless the
+     * application defines its own Horde_Notification_Listener subclass that
+     * handles additional codes.
+     *
+     * @param mixed $event   Horde_Notification_Event object or message string.
+     * @param integer $type  The type of message: 'horde.error',
+     *                       'horde.warning', 'horde.success', or
+     *                       'horde.message'.
+     * @param array $flags   Array of optional flags that will be passed to the
+     *                       registered listeners.
+     */
+    public function push($event, $type = null, array $flags = array())
+    {
+        if ($event instanceof PEAR_Error || $event instanceof Exception) {
+            /**
+             * Some loggers only accept string messages. As both PEAR_Error and
+             * Exception accept being casted into a string we can ensure that
+             * the logger receives a string here.
+             */
+            $this->_logger->debug((string) $event);
+        }
+        $this->_handler->push($event, $type, $flags);
+    }
+
+    /**
+     * Passes the message stack to all listeners and asks them to
+     * handle their messages.
+     *
+     * @param array $options  An array containing display options for the
+     *                        listeners.
+     */
+    public function notify(array $options = array())
+    {
+        $this->_handler->notify($options);
+    }
+
+    /**
+     * Convert the 'listeners' option into the format expected by the
+     * notification handler.
+     *
+     * @param array $options  An array containing display options for the
+     *                        listeners.
+     */
+    public function setNotificationListeners(array &$options)
+    {
+        $this->_handler->setNotificationListeners($options);
+    }
+
+    /**
+     * Passes the message stack to all listeners and asks them to
+     * handle their messages.
+     *
+     * @param array $options An array containing display options for the
+     *                       listeners. This array is required to contain the
+     *                       correct lowercased listener names as array in the
+     *                       entry 'listeners'.
+     */
+    public function notifyListeners(array $options)
+    {
+        $this->_handler->notifyListeners($options);
+    }
+
+    /**
+     * Return the number of notification messages in the stack.
+     *
+     * @author David Ulevitch <davidu@everydns.net>
+     *
+     * @param string $my_listener  The name of the listener.
+     *
+     * @return integer  The number of messages in the stack.
+     */
+    public function count($my_listener = null)
+    {
+        return $this->_handler->count($my_listener);
+    }
+}
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Hordelog.php b/framework/Notification/lib/Horde/Notification/Handler/Hordelog.php
deleted file mode 100644 (file)
index 5558f47..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-<?php
-/**
- * The Horde_Notification_Handler_Hordelog logs error events via
- * Horde::logMessage().
- *
- * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jan Schneider <jan@horde.org>
- * @package Horde_Notification
- */
-class Horde_Notification_Handler_Hordelog
-implements Horde_Notification_Handler_Interface
-{
-    /**
-     * The notification handler decorated by this instance.
-     *
-     * @var Horde_Notification_Handler
-     */
-    private $_handler;
-
-    /**
-     * Initialize the notification system, set up any needed session
-     * variables, etc.
-     *
-     * @param Horde_Notification_Handler $handler The handler this instance
-     *                                            provides with logging.
-     */
-    public function __construct(
-        Horde_Notification_Handler_Interface $handler
-    ) {
-        $this->_handler = $handler;
-    }
-
-    /**
-     * Registers a listener with the notification object and includes
-     * the necessary library file dynamically.
-     *
-     * @param string $listener  The name of the listener to attach. These
-     *                          names must be unique; further listeners with
-     *                          the same name will be ignored.
-     * @param array $params     A hash containing any additional configuration
-     *                          or connection parameters a listener driver
-     *                          might need.
-     * @param string $class     The class name from which the driver was
-     *                          instantiated if not the default one. If given
-     *                          you have to include the library file
-     *                          containing this class yourself. This is useful
-     *                          if you want the listener driver to be
-     *                          overriden by an application's implementation.
-     *
-     * @return Horde_Notification_Listener  The listener object.
-     * @throws Horde_Exception
-     */
-    public function attach($listener, $params = null, $class = null)
-    {
-        return $this->_handler->attach($listener, $params, $class);
-    }
-
-    /**
-     * Remove a listener from the notification list. This will discard any
-     * notifications in this listeners stack.
-     *
-     * @param string $listner  The name of the listener to detach.
-     *
-     * @throws Horde_Exception
-     */
-    public function detach($listener)
-    {
-        $this->_handler->detach($listener);
-    }
-
-    /**
-     * Replaces a listener in the notification list. This preserves all
-     * notifications in this listeners stack. If the listener does not exist,
-     * the new listener will be added automatically.
-     *
-     * @param string $listener  See attach().
-     * @param array $params     See attach().
-     * @param string $class     See attach().
-     *
-     * @return Horde_Notification_Listener  See attach()
-     * @throws Horde_Exception
-     */
-    public function replace($listener, array $params = array(), $class = null)
-    {
-        return $this->_handler->replace($listener, $params, $class);
-    }
-
-    /**
-     * Add an event to the Horde message stack.
-     *
-     * The event type parameter should begin with 'horde.' unless the
-     * application defines its own Horde_Notification_Listener subclass that
-     * handles additional codes.
-     *
-     * @param mixed $event   Horde_Notification_Event object or message string.
-     * @param integer $type  The type of message: 'horde.error',
-     *                       'horde.warning', 'horde.success', or
-     *                       'horde.message'.
-     * @param array $flags   Array of optional flags that will be passed to the
-     *                       registered listeners.
-     */
-    public function push($event, $type = null, array $flags = array())
-    {
-        if ($event instanceof PEAR_Error || $event instanceof Exception) {
-            Horde::logMessage($event, __FILE__, __LINE__, PEAR_LOG_DEBUG);
-        }
-        $this->_handler->push($event, $type, $flags);
-    }
-
-    /**
-     * Passes the message stack to all listeners and asks them to
-     * handle their messages.
-     *
-     * @param array $options  An array containing display options for the
-     *                        listeners.
-     */
-    public function notify(array $options = array())
-    {
-        $this->_handler->notify($options);
-    }
-
-    /**
-     * Convert the 'listeners' option into the format expected by the
-     * notification handler.
-     *
-     * @param array $options  An array containing display options for the
-     *                        listeners.
-     */
-    public function setNotificationListeners(array &$options)
-    {
-        $this->_handler->setNotificationListeners($options);
-    }
-
-    /**
-     * Passes the message stack to all listeners and asks them to
-     * handle their messages.
-     *
-     * @param array $options An array containing display options for the
-     *                       listeners. This array is required to contain the
-     *                       correct lowercased listener names as array in the
-     *                       entry 'listeners'.
-     */
-    public function notifyListeners(array $options)
-    {
-        $this->_handler->notifyListeners($options);
-    }
-
-    /**
-     * Return the number of notification messages in the stack.
-     *
-     * @author David Ulevitch <davidu@everydns.net>
-     *
-     * @param string $my_listener  The name of the listener.
-     *
-     * @return integer  The number of messages in the stack.
-     */
-    public function count($my_listener = null)
-    {
-        return $this->_handler->count($my_listener);
-    }
-}
diff --git a/framework/Notification/lib/Horde/Notification/Handler/Logged.php b/framework/Notification/lib/Horde/Notification/Handler/Logged.php
deleted file mode 100644 (file)
index fbf3e10..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-<?php
-/**
- * The Horde_Notification_Handler_Logged logs error events once they are pushed
- * to the stack.
- *
- * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jan Schneider <jan@horde.org>
- * @package Horde_Notification
- */
-class Horde_Notification_Handler_Logged
-implements Horde_Notification_Handler_Interface
-{
-    /**
-     * The notification handler decorated by this instance.
-     *
-     * @var Horde_Notification_Handler
-     */
-    private $_handler;
-
-    /**
-     * The log handler.
-     *
-     * @var mixed
-     */
-    private $_logger;
-
-    /**
-     * Initialize the notification system, set up any needed session
-     * variables, etc.
-     *
-     * @param Horde_Notification_Handler $handler The handler this instance
-     *                                            provides with logging.
-     *
-     * @param mixed                      $logger  The log handler. The provided
-     *                                            instance is required to
-     *                                            implement the debug() function.
-     *                                            You should be able to use a
-     *                                            common Logger here (PEAR Log,
-     *                                            Horde_Log_Logger, or Zend_Log).
-     */
-    public function __construct(
-        Horde_Notification_Handler_Interface $handler,
-        $logger
-    ) {
-        $this->_handler = $handler;
-        $this->_logger  = $logger;
-    }
-
-    /**
-     * Registers a listener with the notification object and includes
-     * the necessary library file dynamically.
-     *
-     * @param string $listener  The name of the listener to attach. These
-     *                          names must be unique; further listeners with
-     *                          the same name will be ignored.
-     * @param array $params     A hash containing any additional configuration
-     *                          or connection parameters a listener driver
-     *                          might need.
-     * @param string $class     The class name from which the driver was
-     *                          instantiated if not the default one. If given
-     *                          you have to include the library file
-     *                          containing this class yourself. This is useful
-     *                          if you want the listener driver to be
-     *                          overriden by an application's implementation.
-     *
-     * @return Horde_Notification_Listener  The listener object.
-     * @throws Horde_Exception
-     */
-    public function attach($listener, $params = null, $class = null)
-    {
-        return $this->_handler->attach($listener, $params, $class);
-    }
-
-    /**
-     * Remove a listener from the notification list. This will discard any
-     * notifications in this listeners stack.
-     *
-     * @param string $listner  The name of the listener to detach.
-     *
-     * @throws Horde_Exception
-     */
-    public function detach($listener)
-    {
-        $this->_handler->detach($listener);
-    }
-
-    /**
-     * Replaces a listener in the notification list. This preserves all
-     * notifications in this listeners stack. If the listener does not exist,
-     * the new listener will be added automatically.
-     *
-     * @param string $listener  See attach().
-     * @param array $params     See attach().
-     * @param string $class     See attach().
-     *
-     * @return Horde_Notification_Listener  See attach()
-     * @throws Horde_Exception
-     */
-    public function replace($listener, array $params = array(), $class = null)
-    {
-        return $this->_handler->replace($listener, $params, $class);
-    }
-
-    /**
-     * Add an event to the Horde message stack.
-     *
-     * The event type parameter should begin with 'horde.' unless the
-     * application defines its own Horde_Notification_Listener subclass that
-     * handles additional codes.
-     *
-     * @param mixed $event   Horde_Notification_Event object or message string.
-     * @param integer $type  The type of message: 'horde.error',
-     *                       'horde.warning', 'horde.success', or
-     *                       'horde.message'.
-     * @param array $flags   Array of optional flags that will be passed to the
-     *                       registered listeners.
-     */
-    public function push($event, $type = null, array $flags = array())
-    {
-        if ($event instanceof PEAR_Error || $event instanceof Exception) {
-            /**
-             * Some loggers only accept string messages. As both PEAR_Error and
-             * Exception accept being casted into a string we can ensure that
-             * the logger receives a string here.
-             */
-            $this->_logger->debug((string) $event);
-        }
-        $this->_handler->push($event, $type, $flags);
-    }
-
-    /**
-     * Passes the message stack to all listeners and asks them to
-     * handle their messages.
-     *
-     * @param array $options  An array containing display options for the
-     *                        listeners.
-     */
-    public function notify(array $options = array())
-    {
-        $this->_handler->notify($options);
-    }
-
-    /**
-     * Convert the 'listeners' option into the format expected by the
-     * notification handler.
-     *
-     * @param array $options  An array containing display options for the
-     *                        listeners.
-     */
-    public function setNotificationListeners(array &$options)
-    {
-        $this->_handler->setNotificationListeners($options);
-    }
-
-    /**
-     * Passes the message stack to all listeners and asks them to
-     * handle their messages.
-     *
-     * @param array $options An array containing display options for the
-     *                       listeners. This array is required to contain the
-     *                       correct lowercased listener names as array in the
-     *                       entry 'listeners'.
-     */
-    public function notifyListeners(array $options)
-    {
-        $this->_handler->notifyListeners($options);
-    }
-
-    /**
-     * Return the number of notification messages in the stack.
-     *
-     * @author David Ulevitch <davidu@everydns.net>
-     *
-     * @param string $my_listener  The name of the listener.
-     *
-     * @return integer  The number of messages in the stack.
-     */
-    public function count($my_listener = null)
-    {
-        return $this->_handler->count($my_listener);
-    }
-}
index c02fd82..5be347f 100644 (file)
@@ -34,11 +34,13 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <dir name="Horde">
      <dir name="Notification">
       <dir name="Handler">
-       <file name="Alarm.php" role="php" />
        <file name="Base.php" role="php" />
-       <file name="Hordelog.php" role="php" />
+       <dir name="Decorator">
+        <file name="Alarm.php" role="php" />
+        <file name="Hordelog.php" role="php" />
+        <file name="Log.php" role="php" />
+       </dir> <!-- /lib/Horde/Notification/Handler/Decorator -->
        <file name="Interface.php" role="php" />
-       <file name="Logged.php" role="php" />
       </dir> <!-- /lib/Horde/Notification/Handler -->
       <dir name="Listener">
        <file name="Audio.php" role="php" />
@@ -66,10 +68,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <dir name="Notification">
         <file name="EventTest.php" role="test" />
         <dir name="Handler">
-         <file name="AlarmTest.php" role="test" />
          <file name="BaseTest.php" role="test" />
-         <file name="HordelogTest.php" role="test" />
-         <file name="LoggedTest.php" role="test" />
+         <dir name="Decorator">
+          <file name="AlarmTest.php" role="test" />
+          <file name="HordelogTest.php" role="test" />
+          <file name="LogTest.php" role="test" />
+         </dir> <!-- /test/Horde/Notification/Class/Notification/Handler/Decorator -->
         </dir> <!-- /test/Horde/Notification/Class/Notification/Handler -->
         <file name="ListenerTest.php" role="test" />
         <dir name="Listener">
@@ -94,13 +98,13 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <pearinstaller>
     <min>1.5.4</min>
    </pearinstaller>
-   <extension>
-    <name>gettext</name>
-   </extension>
    <package>
     <name>Util</name>
     <channel>pear.horde.org</channel>
    </package>
+   <extension>
+    <name>gettext</name>
+   </extension>
   </required>
   <optional>
    <package>
@@ -115,11 +119,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </dependencies>
  <phprelease>
   <filelist>
-   <install name="lib/Horde/Notification/Handler/Alarm.php" as="Horde/Notification/Handler/Alarm.php" />
    <install name="lib/Horde/Notification/Handler/Base.php" as="Horde/Notification/Handler/Base.php" />
-   <install name="lib/Horde/Notification/Handler/Hordelog.php" as="Horde/Notification/Handler/Hordelog.php" />
+   <install name="lib/Horde/Notification/Handler/Decorator/Alarm.php" as="Horde/Notification/Handler/Decorator/Alarm.php" />
+   <install name="lib/Horde/Notification/Handler/Decorator/Hordelog.php" as="Horde/Notification/Handler/Decorator/Hordelog.php" />
+   <install name="lib/Horde/Notification/Handler/Decorator/Log.php" as="Horde/Notification/Handler/Decorator/Log.php" />
    <install name="lib/Horde/Notification/Handler/Interface.php" as="Horde/Notification/Handler/Interface.php" />
-   <install name="lib/Horde/Notification/Handler/Logged.php" as="Horde/Notification/Handler/Logged.php" />
    <install name="lib/Horde/Notification/Listener/Audio.php" as="Horde/Notification/Listener/Audio.php" />
    <install name="lib/Horde/Notification/Listener/Javascript.php" as="Horde/Notification/Listener/Javascript.php" />
    <install name="lib/Horde/Notification/Listener/Mobile.php" as="Horde/Notification/Listener/Mobile.php" />
@@ -133,10 +137,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="test/Horde/Notification/Autoload.php" as="Horde/Notification/Autoload.php" />
    <install name="test/Horde/Notification/Class/NotificationTest.php" as="Horde/Notification/Class/NotificationTest.php" />
    <install name="test/Horde/Notification/Class/Notification/EventTest.php" as="Horde/Notification/Class/Notification/EventTest.php" />
-   <install name="test/Horde/Notification/Class/Notification/Handler/AlarmTest.php" as="Horde/Notification/Class/Notification/Handler/AlarmTest.php" />
-   <install name="test/Horde/Notification/Class/Notification/Handler/TestTest.php" as="Horde/Notification/Class/Notification/Handler/BaseTest.php" />
-   <install name="test/Horde/Notification/Class/Notification/Handler/HordelogTest.php" as="Horde/Notification/Class/Notification/Handler/HordelogTest.php" />
-   <install name="test/Horde/Notification/Class/Notification/Handler/LoggedTest.php" as="Horde/Notification/Class/Notification/Handler/LoggedTest.php" />
+   <install name="test/Horde/Notification/Class/Notification/Handler/BaseTest.php" as="Horde/Notification/Class/Notification/Handler/BaseTest.php" />
+   <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php" />
+   <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php" />
+   <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" />
    <install name="test/Horde/Notification/Class/Notification/ListenerTest.php" as="Horde/Notification/Class/Notification/ListenerTest.php" />
    <install name="test/Horde/Notification/Class/Notification/Listener/AudioTest.php" as="Horde/Notification/Class/Notification/Listener/AudioTest.php" />
    <install name="test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php" as="Horde/Notification/Class/Notification/Listener/JavascriptTest.php" />
diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/AlarmTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/AlarmTest.php
deleted file mode 100644 (file)
index 7261b5c..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-/**
- * Test the alarm notification handler class.
- *
- * PHP version 5
- *
- * @category Horde
- * @package  Notification
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Notification
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../../../Autoload.php';
-
-/**
- * Test the alarm notification handler class.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package  Notification
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Notification
- */
-
-class Horde_Notification_Class_Notification_Handler_AlarmTest extends PHPUnit_Framework_TestCase
-{
-    public function setUp()
-    {
-        $this->handler = $this->getMock(
-            'Horde_Notification_Handler_Base', array(), array(), '', false, false
-        );
-        $this->alarm   = $this->getMock('Horde_Alarm');
-        $this->alarm_handler = new Horde_Notification_Handler_Alarm(
-            $this->handler, $this->alarm
-        );
-    }
-
-    public function testMethodNotifyHasPostconditionThatTheAlarmSystemGotNotifiedIfTheStatusListenerShouldBeNotified()
-    {
-        $this->alarm->expects($this->once())
-            ->method('notify')
-            ->with('');
-        $this->handler->expects($this->once())
-            ->method('setNotificationListeners')
-            ->with(array('listeners' => array('status')));
-        $this->handler->expects($this->once())
-            ->method('notifyListeners')
-            ->with(array('listeners' => array('status')));
-        $this->alarm_handler->notify(array('listeners' => array('status')));
-    }
-
-    public function testMethodAttachGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('attach')
-            ->with('listener', array(), 'class')
-            ->will($this->returnValue('instance'));
-        $this->assertEquals(
-            'instance',
-            $this->alarm_handler->attach('listener', array(), 'class')
-        );
-    }
-
-    public function testMethodDetachGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('detach')
-            ->with('listener');
-        $this->alarm_handler->detach('listener');
-    }
-
-    public function testMethodReplaceGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('replace')
-            ->with('listener', array(), 'class')
-            ->will($this->returnValue('instance'));
-        $this->assertEquals(
-            'instance',
-            $this->alarm_handler->replace('listener', array(), 'class')
-        );
-    }
-
-    public function testMethodPushGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('push')
-            ->with('event', 'type', array());
-        $this->alarm_handler->push('event', 'type', array());
-    }
-
-    public function testMethodNotifyGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('setNotificationListeners')
-            ->with(array('listeners' => array('test')));
-        $this->handler->expects($this->once())
-            ->method('notifyListeners')
-            ->with(array('listeners' => array('test')));
-        $this->alarm_handler->notify(array('listeners' => array('test')));
-    }
-
-    public function testMethodSetnotificationlistenersGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('setNotificationListeners')
-            ->with(array());
-        $array = array();
-        $this->alarm_handler->setNotificationListeners($array);
-    }
-
-    public function testMethodNotifylistenersGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('notifyListeners')
-            ->with(array());
-        $this->alarm_handler->notifyListeners(array());
-    }
-
-    public function testMethodCountGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('count')
-            ->with('listener')
-            ->will($this->returnValue(1));
-        $this->assertEquals(1, $this->alarm_handler->count('listener'));
-    }
-
-}
\ No newline at end of file
diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php
new file mode 100644 (file)
index 0000000..962e84e
--- /dev/null
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Test the alarm notification handler class.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Notification
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Notification
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the alarm notification handler class.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Notification
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Notification
+ */
+
+class Horde_Notification_Class_Notification_Handler_Decorator_AlarmTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->handler = $this->getMock(
+            'Horde_Notification_Handler_Base', array(), array(), '', false, false
+        );
+        $this->alarm   = $this->getMock('Horde_Alarm');
+        $this->alarm_handler = new Horde_Notification_Handler_Decorator_Alarm(
+            $this->handler, $this->alarm
+        );
+    }
+
+    public function testMethodNotifyHasPostconditionThatTheAlarmSystemGotNotifiedIfTheStatusListenerShouldBeNotified()
+    {
+        $this->alarm->expects($this->once())
+            ->method('notify')
+            ->with('');
+        $this->handler->expects($this->once())
+            ->method('setNotificationListeners')
+            ->with(array('listeners' => array('status')));
+        $this->handler->expects($this->once())
+            ->method('notifyListeners')
+            ->with(array('listeners' => array('status')));
+        $this->alarm_handler->notify(array('listeners' => array('status')));
+    }
+
+    public function testMethodAttachGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('attach')
+            ->with('listener', array(), 'class')
+            ->will($this->returnValue('instance'));
+        $this->assertEquals(
+            'instance',
+            $this->alarm_handler->attach('listener', array(), 'class')
+        );
+    }
+
+    public function testMethodDetachGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('detach')
+            ->with('listener');
+        $this->alarm_handler->detach('listener');
+    }
+
+    public function testMethodReplaceGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('replace')
+            ->with('listener', array(), 'class')
+            ->will($this->returnValue('instance'));
+        $this->assertEquals(
+            'instance',
+            $this->alarm_handler->replace('listener', array(), 'class')
+        );
+    }
+
+    public function testMethodPushGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('push')
+            ->with('event', 'type', array());
+        $this->alarm_handler->push('event', 'type', array());
+    }
+
+    public function testMethodNotifyGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('setNotificationListeners')
+            ->with(array('listeners' => array('test')));
+        $this->handler->expects($this->once())
+            ->method('notifyListeners')
+            ->with(array('listeners' => array('test')));
+        $this->alarm_handler->notify(array('listeners' => array('test')));
+    }
+
+    public function testMethodSetnotificationlistenersGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('setNotificationListeners')
+            ->with(array());
+        $array = array();
+        $this->alarm_handler->setNotificationListeners($array);
+    }
+
+    public function testMethodNotifylistenersGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('notifyListeners')
+            ->with(array());
+        $this->alarm_handler->notifyListeners(array());
+    }
+
+    public function testMethodCountGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('count')
+            ->with('listener')
+            ->will($this->returnValue(1));
+        $this->assertEquals(1, $this->alarm_handler->count('listener'));
+    }
+
+}
\ No newline at end of file
diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php
new file mode 100644 (file)
index 0000000..7336f63
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+/**
+ * Test the notification handler class that logs to the horde log.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Notification
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Notification
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the notification handler class that logs to the horde log.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Notification
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Notification
+ */
+
+class Horde_Notification_Class_Notification_Handler_Decorator_HordelogTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        @include_once 'Log.php';
+        if (!defined('PEAR_LOG_DEBUG')) {
+            $this->markTestSkipped('The PEAR_LOG_DEBUG constant is not available!');
+        }
+
+        $this->handler = $this->getMock(
+            'Horde_Notification_Handler_Base', array(), array(), '', false, false
+        );
+        $this->logged_handler = new Horde_Notification_Handler_Decorator_Hordelog(
+            $this->handler
+        );
+    }
+
+    public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
+    {
+        $exception = new Exception('test');
+        $this->handler->expects($this->once())
+            ->method('push')
+            ->with($exception);
+        $this->logged_handler->push($exception);
+    }
+
+    public function testMethodAttachGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('attach')
+            ->with('listener', array(), 'class')
+            ->will($this->returnValue('instance'));
+        $this->assertEquals(
+            'instance',
+            $this->logged_handler->attach('listener', array(), 'class')
+        );
+    }
+
+    public function testMethodDetachGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('detach')
+            ->with('listener');
+        $this->logged_handler->detach('listener');
+    }
+
+    public function testMethodReplaceGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('replace')
+            ->with('listener', array(), 'class')
+            ->will($this->returnValue('instance'));
+        $this->assertEquals(
+            'instance',
+            $this->logged_handler->replace('listener', array(), 'class')
+        );
+    }
+
+    public function testMethodPushGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('push')
+            ->with('event', 'type', array());
+        $this->logged_handler->push('event', 'type', array());
+    }
+
+    public function testMethodNotifyGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('notify')
+            ->with(array('listeners' => array('test')));
+        $this->logged_handler->notify(array('listeners' => array('test')));
+    }
+
+    public function testMethodSetnotificationlistenersGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('setNotificationListeners')
+            ->with(array());
+        $array = array();
+        $this->logged_handler->setNotificationListeners($array);
+    }
+
+    public function testMethodNotifylistenersGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('notifyListeners')
+            ->with(array());
+        $this->logged_handler->notifyListeners(array());
+    }
+
+    public function testMethodCountGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('count')
+            ->with('listener')
+            ->will($this->returnValue(1));
+        $this->assertEquals(1, $this->logged_handler->count('listener'));
+    }
+
+}
\ No newline at end of file
diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php
new file mode 100644 (file)
index 0000000..841e7fa
--- /dev/null
@@ -0,0 +1,134 @@
+<?php
+/**
+ * Test the logging notification handler class.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Notification
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Notification
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../../Autoload.php';
+
+/**
+ * Test the logging notification handler class.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Notification
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Notification
+ */
+
+class Horde_Notification_Class_Notification_Handler_Decorator_LogTest
+extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->handler = $this->getMock(
+            'Horde_Notification_Handler_Base', array(), array(), '', false, false
+        );
+        $this->logger   = $this->getMock('Horde_Log_Logger');
+        $this->logged_handler = new Horde_Notification_Handler_Decorator_Log(
+            $this->handler, $this->logger
+        );
+    }
+
+    public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
+    {
+        $exception = new Exception('test');
+        $this->logger->expects($this->once())
+            ->method('__call')
+            ->with('debug', $this->isType('array'));
+        $this->handler->expects($this->once())
+            ->method('push')
+            ->with($exception);
+        $this->logged_handler->push($exception);
+    }
+
+    public function testMethodAttachGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('attach')
+            ->with('listener', array(), 'class')
+            ->will($this->returnValue('instance'));
+        $this->assertEquals(
+            'instance',
+            $this->logged_handler->attach('listener', array(), 'class')
+        );
+    }
+
+    public function testMethodDetachGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('detach')
+            ->with('listener');
+        $this->logged_handler->detach('listener');
+    }
+
+    public function testMethodReplaceGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('replace')
+            ->with('listener', array(), 'class')
+            ->will($this->returnValue('instance'));
+        $this->assertEquals(
+            'instance',
+            $this->logged_handler->replace('listener', array(), 'class')
+        );
+    }
+
+    public function testMethodPushGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('push')
+            ->with('event', 'type', array());
+        $this->logged_handler->push('event', 'type', array());
+    }
+
+    public function testMethodNotifyGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('notify')
+            ->with(array('listeners' => array('test')));
+        $this->logged_handler->notify(array('listeners' => array('test')));
+    }
+
+    public function testMethodSetnotificationlistenersGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('setNotificationListeners')
+            ->with(array());
+        $array = array();
+        $this->logged_handler->setNotificationListeners($array);
+    }
+
+    public function testMethodNotifylistenersGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('notifyListeners')
+            ->with(array());
+        $this->logged_handler->notifyListeners(array());
+    }
+
+    public function testMethodCountGetsDelegated()
+    {
+        $this->handler->expects($this->once())
+            ->method('count')
+            ->with('listener')
+            ->will($this->returnValue(1));
+        $this->assertEquals(1, $this->logged_handler->count('listener'));
+    }
+
+}
\ No newline at end of file
diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/HordelogTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/HordelogTest.php
deleted file mode 100644 (file)
index 77bd66c..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-/**
- * Test the notification handler class that logs to the horde log.
- *
- * PHP version 5
- *
- * @category Horde
- * @package  Notification
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Notification
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../../../Autoload.php';
-
-/**
- * Test the notification handler class that logs to the horde log.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package  Notification
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Notification
- */
-
-class Horde_Notification_Class_Notification_Handler_HordelogTest extends PHPUnit_Framework_TestCase
-{
-    public function setUp()
-    {
-        @include_once 'Log.php';
-        if (!defined('PEAR_LOG_DEBUG')) {
-            $this->markTestSkipped('The PEAR_LOG_DEBUG constant is not available!');
-        }
-
-        $this->handler = $this->getMock(
-            'Horde_Notification_Handler_Base', array(), array(), '', false, false
-        );
-        $this->logged_handler = new Horde_Notification_Handler_Hordelog(
-            $this->handler
-        );
-    }
-
-    public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
-    {
-        $exception = new Exception('test');
-        $this->handler->expects($this->once())
-            ->method('push')
-            ->with($exception);
-        $this->logged_handler->push($exception);
-    }
-
-    public function testMethodAttachGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('attach')
-            ->with('listener', array(), 'class')
-            ->will($this->returnValue('instance'));
-        $this->assertEquals(
-            'instance',
-            $this->logged_handler->attach('listener', array(), 'class')
-        );
-    }
-
-    public function testMethodDetachGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('detach')
-            ->with('listener');
-        $this->logged_handler->detach('listener');
-    }
-
-    public function testMethodReplaceGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('replace')
-            ->with('listener', array(), 'class')
-            ->will($this->returnValue('instance'));
-        $this->assertEquals(
-            'instance',
-            $this->logged_handler->replace('listener', array(), 'class')
-        );
-    }
-
-    public function testMethodPushGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('push')
-            ->with('event', 'type', array());
-        $this->logged_handler->push('event', 'type', array());
-    }
-
-    public function testMethodNotifyGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('notify')
-            ->with(array('listeners' => array('test')));
-        $this->logged_handler->notify(array('listeners' => array('test')));
-    }
-
-    public function testMethodSetnotificationlistenersGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('setNotificationListeners')
-            ->with(array());
-        $array = array();
-        $this->logged_handler->setNotificationListeners($array);
-    }
-
-    public function testMethodNotifylistenersGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('notifyListeners')
-            ->with(array());
-        $this->logged_handler->notifyListeners(array());
-    }
-
-    public function testMethodCountGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('count')
-            ->with('listener')
-            ->will($this->returnValue(1));
-        $this->assertEquals(1, $this->logged_handler->count('listener'));
-    }
-
-}
\ No newline at end of file
diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/LoggedTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/LoggedTest.php
deleted file mode 100644 (file)
index 2b56cd6..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-/**
- * Test the logging notification handler class.
- *
- * PHP version 5
- *
- * @category Horde
- * @package  Notification
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Notification
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../../../Autoload.php';
-
-/**
- * Test the logging notification handler class.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package  Notification
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Notification
- */
-
-class Horde_Notification_Class_Notification_Handler_LoggedTest extends PHPUnit_Framework_TestCase
-{
-    public function setUp()
-    {
-        $this->handler = $this->getMock(
-            'Horde_Notification_Handler_Base', array(), array(), '', false, false
-        );
-        $this->logger   = $this->getMock('Horde_Log_Logger');
-        $this->logged_handler = new Horde_Notification_Handler_Logged(
-            $this->handler, $this->logger
-        );
-    }
-
-    public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
-    {
-        $exception = new Exception('test');
-        $this->logger->expects($this->once())
-            ->method('__call')
-            ->with('debug', $this->isType('array'));
-        $this->handler->expects($this->once())
-            ->method('push')
-            ->with($exception);
-        $this->logged_handler->push($exception);
-    }
-
-    public function testMethodAttachGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('attach')
-            ->with('listener', array(), 'class')
-            ->will($this->returnValue('instance'));
-        $this->assertEquals(
-            'instance',
-            $this->logged_handler->attach('listener', array(), 'class')
-        );
-    }
-
-    public function testMethodDetachGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('detach')
-            ->with('listener');
-        $this->logged_handler->detach('listener');
-    }
-
-    public function testMethodReplaceGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('replace')
-            ->with('listener', array(), 'class')
-            ->will($this->returnValue('instance'));
-        $this->assertEquals(
-            'instance',
-            $this->logged_handler->replace('listener', array(), 'class')
-        );
-    }
-
-    public function testMethodPushGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('push')
-            ->with('event', 'type', array());
-        $this->logged_handler->push('event', 'type', array());
-    }
-
-    public function testMethodNotifyGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('notify')
-            ->with(array('listeners' => array('test')));
-        $this->logged_handler->notify(array('listeners' => array('test')));
-    }
-
-    public function testMethodSetnotificationlistenersGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('setNotificationListeners')
-            ->with(array());
-        $array = array();
-        $this->logged_handler->setNotificationListeners($array);
-    }
-
-    public function testMethodNotifylistenersGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('notifyListeners')
-            ->with(array());
-        $this->logged_handler->notifyListeners(array());
-    }
-
-    public function testMethodCountGetsDelegated()
-    {
-        $this->handler->expects($this->once())
-            ->method('count')
-            ->with('listener')
-            ->will($this->returnValue(1));
-        $this->assertEquals(1, $this->logged_handler->count('listener'));
-    }
-
-}
\ No newline at end of file
index 2a8c592..59791a0 100644 (file)
@@ -46,7 +46,7 @@ class Horde_Notification_Class_NotificationTest extends PHPUnit_Framework_TestCa
         $conf['alarms']['driver'] = 'Mock';
 
         $this->assertType(
-            'Horde_Notification_Handler_Alarm',
+            'Horde_Notification_Handler_Decorator_Alarm',
             Horde_Notification::singleton('alarm')
         );
     }