3 * Test the notification handler class that logs to the horde log.
6 * @package Notification
7 * @author Gunnar Wrobel <wrobel@pardus.de>
8 * @license http://www.fsf.org/copyleft/lgpl.html LGPL
9 * @link http://pear.horde.org/index.php?package=Notification
13 * Prepare the test setup.
15 require_once dirname(__FILE__) . '/../../../../Autoload.php';
18 * Test the notification handler class that logs to the horde log.
20 * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
22 * See the enclosed file COPYING for license information (LGPL). If you
23 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
26 * @package Notification
27 * @author Gunnar Wrobel <wrobel@pardus.de>
28 * @license http://www.fsf.org/copyleft/lgpl.html LGPL
29 * @link http://pear.horde.org/index.php?package=Notification
32 class Horde_Notification_Class_Notification_Handler_Decorator_HordelogTest
33 extends PHPUnit_Framework_TestCase
35 public function setUp()
37 if (!class_exists('Log')) {
38 $this->markTestSkipped('The PEAR Log package is not installed!');
41 @include_once 'Log.php';
42 if (!defined('PEAR_LOG_DEBUG')) {
43 $this->markTestSkipped('The PEAR_LOG_DEBUG constant is not available!');
46 $this->handler = $this->getMock(
47 'Horde_Notification_Handler_Base', array(), array(), '', false, false
49 $this->logged_handler = new Horde_Notification_Handler_Decorator_Hordelog(
54 public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
56 $exception = new Exception('test');
57 $this->handler->expects($this->once())
60 $this->logged_handler->push($exception);
63 public function testMethodAttachGetsDelegated()
65 $this->handler->expects($this->once())
67 ->with('listener', array(), 'class')
68 ->will($this->returnValue('instance'));
71 $this->logged_handler->attach('listener', array(), 'class')
75 public function testMethodDetachGetsDelegated()
77 $this->handler->expects($this->once())
80 $this->logged_handler->detach('listener');
83 public function testMethodReplaceGetsDelegated()
85 $this->handler->expects($this->once())
87 ->with('listener', array(), 'class')
88 ->will($this->returnValue('instance'));
91 $this->logged_handler->replace('listener', array(), 'class')
95 public function testMethodPushGetsDelegated()
97 $this->handler->expects($this->once())
99 ->with('event', 'type', array());
100 $this->logged_handler->push('event', 'type', array());
103 public function testMethodNotifyGetsDelegated()
105 $this->handler->expects($this->once())
107 ->with(array('listeners' => array('test')));
108 $this->logged_handler->notify(array('listeners' => array('test')));
111 public function testMethodSetnotificationlistenersGetsDelegated()
113 $this->handler->expects($this->once())
114 ->method('setNotificationListeners')
117 $this->logged_handler->setNotificationListeners($array);
120 public function testMethodNotifylistenersGetsDelegated()
122 $this->handler->expects($this->once())
123 ->method('notifyListeners')
125 $this->logged_handler->notifyListeners(array());
128 public function testMethodCountGetsDelegated()
130 $this->handler->expects($this->once())
133 ->will($this->returnValue(1));
134 $this->assertEquals(1, $this->logged_handler->count('listener'));