コード例 #1
0
 public function testValidEventSubscriber()
 {
     $services = array('my_event_subscriber' => array(0 => array()));
     $definition = $this->getMock('Symfony\\Component\\DependencyInjection\\Definition');
     $definition->expects($this->atLeastOnce())->method('getClass')->will($this->returnValue('Symfony\\Bundle\\FrameworkBundle\\Tests\\DependencyInjection\\Compiler\\SubscriberService'));
     $builder = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $builder->expects($this->any())->method('hasDefinition')->will($this->returnValue(true));
     // We don't test kernel.event_listener here
     $builder->expects($this->atLeastOnce())->method('findTaggedServiceIds')->will($this->onConsecutiveCalls(array(), $services));
     $builder->expects($this->atLeastOnce())->method('getDefinition')->will($this->returnValue($definition));
     $registerListenersPass = new RegisterKernelListenersPass();
     $registerListenersPass->process($builder);
 }
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded.
  */
 public function testAbstractEventListener()
 {
     $container = new ContainerBuilder();
     $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array());
     $container->register('event_dispatcher', 'stdClass');
     $registerListenersPass = new RegisterKernelListenersPass();
     $registerListenersPass->process($container);
 }