public function testStaticCallable()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $dispatcher = new ContainerAwareTraceableEventDispatcher($container, new StopWatch());
     $dispatcher->addListener('onFooEvent', array(__NAMESPACE__ . '\\StaticClassFixture', 'staticListener'));
     $dispatcher->dispatch('onFooEvent');
     $this->assertTrue(StaticClassFixture::$called);
 }
 public function testClosureDoesNotTriggerErrorNotice()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $dispatcher = new ContainerAwareTraceableEventDispatcher($container, new StopWatch());
     $triggered = false;
     $dispatcher->addListener('onFooEvent', function () use(&$triggered) {
         $triggered = true;
     });
     try {
         $dispatcher->dispatch('onFooEvent');
     } catch (\PHPUnit_Framework_Error_Notice $e) {
         $this->fail($e->getMessage());
     }
     $this->assertTrue($triggered, 'Closure should have been executed upon dispatch');
 }
 public function addListenerService($eventName, $callback, $priority = 0)
 {
     if (!is_array($callback) || 2 !== count($callback)) {
         throw new \InvalidArgumentException('Expected an array("service", "method") argument');
     }
     $bundle = $this->kernel->getBundleByServiceId($callback[0]);
     // skip inactive module bundles
     if (!$bundle || !$bundle instanceof AbstractModule || $bundle instanceof AbstractModule && $this->kernel->isModuleBundleActive($bundle)) {
         parent::addListenerService($eventName, $callback, $priority);
     }
 }