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 if (!class_exists('Log')) {
40 $this->markTestSkipped('The PEAR Log package is not installed!');
43 @include_once 'Log.php';
44 if (!defined('PEAR_LOG_DEBUG')) {
45 $this->markTestSkipped('The PEAR_LOG_DEBUG constant is not available!');
48 $this->handler = $this->getMock(
49 'Horde_Notification_Handler_Base', array(), array(), '', false, false
51 $this->logged_handler = new Horde_Notification_Handler_Decorator_Hordelog(
56 public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
58 $exception = new Exception('test');
59 $this->handler->expects($this->once())
62 $this->logged_handler->push($exception);
65 public function testMethodAttachGetsDelegated()
67 $this->handler->expects($this->once())
69 ->with('listener', array(), 'class')
70 ->will($this->returnValue('instance'));
73 $this->logged_handler->attach('listener', array(), 'class')
77 public function testMethodDetachGetsDelegated()
79 $this->handler->expects($this->once())
82 $this->logged_handler->detach('listener');
85 public function testMethodReplaceGetsDelegated()
87 $this->handler->expects($this->once())
89 ->with('listener', array(), 'class')
90 ->will($this->returnValue('instance'));
93 $this->logged_handler->replace('listener', array(), 'class')
97 public function testMethodPushGetsDelegated()
99 $this->handler->expects($this->once())
101 ->with('event', 'type', array());
102 $this->logged_handler->push('event', 'type', array());
105 public function testMethodNotifyGetsDelegated()
107 $this->handler->expects($this->once())
109 ->with(array('listeners' => array('test')));
110 $this->logged_handler->notify(array('listeners' => array('test')));
113 public function testMethodSetnotificationlistenersGetsDelegated()
115 $this->handler->expects($this->once())
116 ->method('setNotificationListeners')
119 $this->logged_handler->setNotificationListeners($array);
122 public function testMethodNotifylistenersGetsDelegated()
124 $this->handler->expects($this->once())
125 ->method('notifyListeners')
127 $this->logged_handler->notifyListeners(array());
130 public function testMethodCountGetsDelegated()
132 $this->handler->expects($this->once())
135 ->will($this->returnValue(1));
136 $this->assertEquals(1, $this->logged_handler->count('listener'));