/**
  * Issue #2 - Higher priority handles don't stop lower priority listeners from seeing event.
  *
  * @param MockListener $listener
  * @param Event        $event
  *
  * @throws \DomainException
  * @throws \InvalidArgumentException
  */
 public function it_should_only_call_listeners_for_event_until_one_of_them_handles_the_event(MockListener $listener, Event $event)
 {
     $event->hasBeenHandled()->willReturn(true)->shouldBeCalled();
     $listener->method2($event, 'test1', $this)->willReturn($event);
     $this->addListener('test1', [$listener, 'method2']);
     $this->addListener('test1', [$listener, 'method1'], 'last');
     $this->getListeners()->shouldHaveKey('test1');
     $expected = [0 => [[$listener, 'method2']], -1 => [[$listener, 'method1']]];
     $this->getListeners('test1')->shouldReturn($expected);
     $listener->method2($event, 'test1', $this)->shouldBeCalled();
     $listener->method1($event, 'test1', $this)->shouldNotBeCalled();
     $this->trigger('test1', $event);
 }
 /**
  * @param MockListener          $listener
  * @param Event                 $event
  * @param Container             $container
  * @param MockServiceSubscriber $sub
  *
  * @throws \DomainException
  * @throws \InvalidArgumentException
  * @throws \LengthException
  * @throws \LogicException
  */
 public function it_should_still_allow_service_subscriber_to_be_removed_after_event_has_been_triggered(MockListener $listener, Event $event, Container $container, MockServiceSubscriber $sub)
 {
     $events = ['test1' => [[['containerID1', 'method1']]]];
     $event->hasBeenHandled()->willReturn(false);
     $sub->getServiceSubscribedEvents()->willReturn($events);
     $this->addServiceSubscriber($sub);
     $this->getServiceListeners()->shouldHaveKey('test1');
     $container->offsetGet('containerID1')->willReturn($listener);
     $this->setServiceContainer($container);
     $listener->method1($event, 'test1', $this)->shouldBeCalled();
     $this->getServiceByName('containerID1')->shouldReturn($listener);
     $this->trigger('test1', $event);
     $this->removeServiceSubscriber($sub);
     $this->getServiceListeners()->shouldNotHaveKey('test1');
 }