$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()
);
}
+++ /dev/null
-<?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);
- }
-
-}
--- /dev/null
+<?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);
+ }
+
+}
--- /dev/null
+<?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);
+ }
+}
--- /dev/null
+<?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);
+ }
+}
+++ /dev/null
-<?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);
- }
-}
+++ /dev/null
-<?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);
- }
-}
<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" />
<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">
<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>
</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" />
<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" />
+++ /dev/null
-<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
+++ /dev/null
-<?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
+++ /dev/null
-<?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
$conf['alarms']['driver'] = 'Mock';
$this->assertType(
- 'Horde_Notification_Handler_Alarm',
+ 'Horde_Notification_Handler_Decorator_Alarm',
Horde_Notification::singleton('alarm')
);
}