Exemplo n.º 1
0
 /**
  */
 public function testRemoveListener()
 {
     $this->object->on('test.event', array($this, 'eventFunction'));
     $this->object->notify(new Event('test.event'));
     $this->assertTrue($GLOBALS['testEvent']);
     $GLOBALS['testEvent'] = false;
     $this->object->removeListener('test.event', array($this, 'eventFunction'));
     $this->object->notify(new Event('test.event'));
     $this->assertFalse($GLOBALS['testEvent']);
     $this->assertInstanceOf('Fwk\\Events\\Dispatcher', $this->object->removeListener('inexistant.event', array()));
 }
Exemplo n.º 2
0
 /**
  */
 public function testRemoveListener()
 {
     $eventName = 'test';
     $dispatcher = new Dispatcher();
     $listener = new Listener($eventName);
     $dispatcher->addListener($eventName, $listener);
     $dispatcher->removeListener($eventName, $listener);
     $this->assertEmpty($dispatcher->getListeners());
 }