/** * Returns the instance of the event dispatcher. * * @return OX_Admin_UI_Event_EventDispatcher */ public function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
function testCallNonExistentEventWithModifyingContext() { $dispatcher = new OX_Admin_UI_Event_EventDispatcher(); $listener = array(new Test_OX_Admin_UI_Event_ModifyingTestEventListener(), 'onUpdate'); $eventName = "onFakeEvent"; $dummyObject = new TestDummyObject(); $context = new OX_Admin_UI_Event_EventContext(); $context->data = array(1, "2", "three", "dummy" => $dummyObject); $dispatcher->register($eventName, $listener); //invoke event by proxy $dispatcher->{$eventName}($context); //check if listener was actually invoked $this->assertEqual(1, $listener[0]->aCallCount[$eventName]['count']); $this->assertEqual($context, $listener[0]->aCallCount[$eventName]['lastContext']); $this->assertReference($dummyObject, $listener[0]->aCallCount[$eventName]['lastContext']->data['dummy']); //check if back modifications were passed on to the context $tmp = $context->{$eventName}; $this->assertEqual(1, $tmp['count']); $this->assertReference($dummyObject, $context->data['dummy']); $this->assertIdentical($dummyObject, $listener[0]->aCallCount[$eventName]['lastContext']->data['dummy']); $this->assertTrue(isset($dummyObject->id)); }
/** * Retrieves an instance of event dispatcher * * @return OX_Admin_UI_Event_EventDispatcher */ private static function getDispatcher() { $oDispatcher = OX_Admin_UI_Event_EventDispatcher::getInstance(); return $oDispatcher; }