Example #1
0
 public function testAddListeners()
 {
     $em = new EventManager();
     $listeners = array(array($this, 'listenerOne'), array($this, 'listenerTwo'), array(new \stdClass(), 'listenerThree'));
     $em->addListeners('boundEvent', $listeners);
     $this->assertCount(3, $em->getListeners('boundEvent'));
 }
Example #2
0
 public function testStopPropagation()
 {
     $em = new EventManager();
     $instanceOne = new StopPropagationListener();
     $instanceTwo = new StopPropagationListener();
     $em->addListeners('stopPropagationEvent', array(array($instanceOne, 'listener'), array($instanceTwo, 'listener')));
     $event = new Event();
     $this->assertFalse($event->propagationHalted());
     $em->dispatch('stopPropagationEvent', $event);
     $this->assertTrue($instanceOne->listenerCalled);
     $this->assertFalse($instanceTwo->listenerCalled);
     $this->assertTrue($event->propagationHalted());
 }