--- /dev/null
+<?php
+/**
+ * Test the status event class.
+ *
+ * @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 status event class.
+ *
+ * Copyright 2009-2010 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_Event_StatusTest extends PHPUnit_Framework_TestCase
+{
+ public function testMethodTostringHasResultTheTextOfTheEvent()
+ {
+ if (!class_exists('Horde_Nls')) {
+ $this->markTestSkipped('The Horde_Nls class is not available!');
+ }
+ Horde_Nls::setCharset('ISO-8859-1');
+ $event = new Horde_Notification_Event_Status('<b>test</b>');
+ $this->assertEquals('<b>test</b>', (string) $event);
+ }
+
+ public function testMethodTostringHasUnescapedResultIfContentRawFlagIsSet()
+ {
+ $event = new Horde_Notification_Event_Status('<b>test</b>', null, array('content.raw'));
+ $this->assertEquals('<b>test</b>', (string) $event);
+ }
+
+}
}
}
+ public function testMethodClearHasPostconditionThatTheStorageOfTheSpecifiedListenerWasCleared()
+ {
+ $storage = $this->getMock('Horde_Notification_Storage_Interface');
+ $storage->expects($this->once())
+ ->method('clear')
+ ->with('dummy');
+ $handler = new Horde_Notification_Handler($storage);
+ $handler->attach('dummy');
+ $handler->clear('dummy');
+ }
+
+ public function testMethodClearHasPostconditionThatAllUnattachedEventsHaveBeenClearedFromStorageIfNoListenerWasSpecified()
+ {
+ $storage = $this->getMock('Horde_Notification_Storage_Interface');
+ $storage->expects($this->once())
+ ->method('clear')
+ ->with('_unattached');
+ $handler = new Horde_Notification_Handler($storage);
+ $handler->clear();
+ }
+
+ public function testMethodGetHasResultNullIfTheSpecifiedListenerIsNotAttached()
+ {
+ $this->assertNull($this->handler->get('not attached'));
+ }
+
+ public function testMethodAddtypeHasPostconditionThatTheSpecifiedListenerHandlesTheGivenMessageType()
+ {
+ $this->handler->attach('dummy');
+ $this->handler->addType('dummy', 'newtype', 'NewType');
+ $this->assertEquals('NewType', $this->handler->getListener('dummy')->handles('newtype'));
+ }
+
+ public function testMethodAdddecoratorHasPostconditionThatTheGivenDecoratorWasAddedToTheHandlerAndReceivesPushCalls()
+ {
+ $decorator = $this->getMock('Horde_Notification_Handler_Decorator_Base');
+ $decorator->expects($this->once())
+ ->method('push')
+ ->with($this->isInstanceOf('Horde_Notification_Event'));
+ $event = new Horde_Notification_Event('test');
+ $this->handler->attach('audio');
+ $this->handler->addDecorator($decorator);
+ $this->handler->push($event, 'audio');
+ }
+
+ public function testMethodAdddecoratorHasPostconditionThatTheGivenDecoratorWasAddedToTheHandlerAndReceivesNotifyCalls()
+ {
+ $decorator = $this->getMock('Horde_Notification_Handler_Decorator_Base');
+ $decorator->expects($this->once())
+ ->method('notify');
+ $this->handler->attach('audio');
+ $this->handler->addDecorator($decorator);
+ $this->handler->notify();
+ }
+
public function testMethodPushHasPostconditionThatTheEventGotSavedInAllAttachedListenerStacksHandlingTheEvent()
{
$event = new Horde_Notification_Event('test');
$listener->notify($messages);
}
+ public function testMethodNotifyHasMobileOutputIfTheMobileOptionWasSet()
+ {
+ if (!class_exists('Horde_Mobile')) {
+ $this->markTestSkipped('The Horde_Mobile package is not installed!');
+ }
+ $mobile = $this->getMock('Horde_Mobile', array(), array(), '', false, false);
+ $mobile->expects($this->once())
+ ->method('add')
+ ->with($this->isInstanceOf('Horde_Mobile_Text'));
+ $listener = new Horde_Notification_Listener_Status();
+ $event = new Horde_Notification_Event('<b>test</b>');
+ $messages = array($event);
+ $listener->notify($messages, array('mobile' => $mobile));
+ }
+
}
$this->assertEquals('Horde_Notification_Event', $listener->handles('mock'));
}
+ public function testMethodHandleHasEventClassNameIfItMatchesAsteriskExpression()
+ {
+ $listener = new Horde_Notification_Listener_Mock();
+ $listener->addType('t*', 'Test_Event');
+ $this->assertEquals('Test_Event', $listener->handles('test'));
+ }
+
public function testMethodGetnameHasResultStringTheNameOfTheListener()
{
$listener = new Horde_Notification_Listener_Mock();