You are here

public function RegisterListenersPassTest::testValidEventSubscriber in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php \Symfony\Component\EventDispatcher\Tests\DependencyInjection\RegisterListenersPassTest::testValidEventSubscriber()

File

vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php, line 61

Class

RegisterListenersPassTest

Namespace

Symfony\Component\EventDispatcher\Tests\DependencyInjection

Code

public function testValidEventSubscriber() {
  $services = array(
    'my_event_subscriber' => array(
      0 => array(),
    ),
  );
  $definition = $this
    ->getMock('Symfony\\Component\\DependencyInjection\\Definition');
  $definition
    ->expects($this
    ->atLeastOnce())
    ->method('isPublic')
    ->will($this
    ->returnValue(true));
  $definition
    ->expects($this
    ->atLeastOnce())
    ->method('getClass')
    ->will($this
    ->returnValue('Symfony\\Component\\EventDispatcher\\Tests\\DependencyInjection\\SubscriberService'));
  $builder = $this
    ->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder', array(
    'hasDefinition',
    'findTaggedServiceIds',
    'getDefinition',
    'findDefinition',
  ));
  $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));
  $builder
    ->expects($this
    ->atLeastOnce())
    ->method('findDefinition')
    ->will($this
    ->returnValue($definition));
  $registerListenersPass = new RegisterListenersPass();
  $registerListenersPass
    ->process($builder);
}