3 * Test the notification handler class that logs to the horde log.
8 * @package Notification
9 * @author Gunnar Wrobel <wrobel@pardus.de>
10 * @license http://www.fsf.org/copyleft/lgpl.html LGPL
11 * @link http://pear.horde.org/index.php?package=Notification
15 * Prepare the test setup.
17 require_once dirname(__FILE__) . '/../../../../Autoload.php';
20 * Test the notification handler class that logs to the horde log.
22 * Copyright 2009 The Horde Project (http://www.horde.org/)
24 * See the enclosed file COPYING for license information (LGPL). If you
25 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
28 * @package Notification
29 * @author Gunnar Wrobel <wrobel@pardus.de>
30 * @license http://www.fsf.org/copyleft/lgpl.html LGPL
31 * @link http://pear.horde.org/index.php?package=Notification
34 class Horde_Notification_Class_Notification_Handler_Decorator_HordelogTest
35 extends PHPUnit_Framework_TestCase
37 public function setUp()
39 @include_once 'Log.php';
40 if (!defined('PEAR_LOG_DEBUG')) {
41 $this->markTestSkipped('The PEAR_LOG_DEBUG constant is not available!');
44 $this->handler = $this->getMock(
45 'Horde_Notification_Handler_Base', array(), array(), '', false, false
47 $this->logged_handler = new Horde_Notification_Handler_Decorator_Hordelog(
52 public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
54 $exception = new Exception('test');
55 $this->handler->expects($this->once())
58 $this->logged_handler->push($exception);
61 public function testMethodAttachGetsDelegated()
63 $this->handler->expects($this->once())
65 ->with('listener', array(), 'class')
66 ->will($this->returnValue('instance'));
69 $this->logged_handler->attach('listener', array(), 'class')
73 public function testMethodDetachGetsDelegated()
75 $this->handler->expects($this->once())
78 $this->logged_handler->detach('listener');
81 public function testMethodReplaceGetsDelegated()
83 $this->handler->expects($this->once())
85 ->with('listener', array(), 'class')
86 ->will($this->returnValue('instance'));
89 $this->logged_handler->replace('listener', array(), 'class')
93 public function testMethodPushGetsDelegated()
95 $this->handler->expects($this->once())
97 ->with('event', 'type', array());
98 $this->logged_handler->push('event', 'type', array());
101 public function testMethodNotifyGetsDelegated()
103 $this->handler->expects($this->once())
105 ->with(array('listeners' => array('test')));
106 $this->logged_handler->notify(array('listeners' => array('test')));
109 public function testMethodSetnotificationlistenersGetsDelegated()
111 $this->handler->expects($this->once())
112 ->method('setNotificationListeners')
115 $this->logged_handler->setNotificationListeners($array);
118 public function testMethodNotifylistenersGetsDelegated()
120 $this->handler->expects($this->once())
121 ->method('notifyListeners')
123 $this->logged_handler->notifyListeners(array());
126 public function testMethodCountGetsDelegated()
128 $this->handler->expects($this->once())
131 ->will($this->returnValue(1));
132 $this->assertEquals(1, $this->logged_handler->count('listener'));