/**
  * @see https://bugs.php.net/bug.php?id=62976
  *
  * This bug affects:
  *  - The PHP 5.3 branch for versions < 5.3.18
  *  - The PHP 5.4 branch for versions < 5.4.8
  *  - The PHP 5.5 branch is not affected
  */
 public function testWorkaroundForPhpBug62976()
 {
     $dispatcher = new ContainerAwareEventDispatcher(new Container());
     $dispatcher->addListener('bug.62976', new CallableClass());
     $dispatcher->removeListener('bug.62976', function () {
     });
     $this->assertTrue($dispatcher->hasListeners('bug.62976'));
 }
 public function testRemoveService()
 {
     $container = new ContainerBuilder();
     $container->register('listener_service', 'Symfony\\Component\\EventDispatcher\\Tests\\TestEventListener');
     $container->register('other_listener_service', 'Symfony\\Component\\EventDispatcher\\Tests\\TestEventListener');
     $listeners = array('test_event' => array(0 => array(array('service' => array('listener_service', 'preFoo')), array('service' => array('other_listener_service', 'preFoo')))));
     $dispatcher = new ContainerAwareEventDispatcher($container, $listeners);
     $listenerService = $container->get('listener_service');
     $dispatcher->removeListener('test_event', array($listenerService, 'preFoo'));
     // Ensure that other service was not initialized during removal of the
     // listener service.
     $this->assertFalse($container->initialized('other_listener_service'));
     $dispatcher->dispatch('test_event');
     $this->assertFalse($listenerService->preFooInvoked);
     $otherService = $container->get('other_listener_service');
     $this->assertTrue($otherService->preFooInvoked);
 }
 public function testGetListenerPriorityWithServices()
 {
     $container = new ContainerBuilder();
     $container->register('listener_service', TestEventListener::class);
     $listeners = array('test_event' => array(5 => array(array('service' => array('listener_service', 'preFoo')))));
     $dispatcher = new ContainerAwareEventDispatcher($container, $listeners);
     $listenerService = $container->get('listener_service');
     $actualPriority = $dispatcher->getListenerPriority('test_event', [$listenerService, 'preFoo']);
     $this->assertSame(5, $actualPriority);
 }