public function ContainerAwareEventDispatcherTest::testAddAListenerService

File

drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php, line 29

Class

ContainerAwareEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

public function testAddAListenerService() {
  $event = new Event();
  $service = $this
    ->getMock('Symfony\\Component\\EventDispatcher\\Tests\\Service');
  $service
    ->expects($this
    ->once())
    ->method('onEvent')
    ->with($event);
  $container = new Container();
  $container
    ->set('service.listener', $service);
  $dispatcher = new ContainerAwareEventDispatcher($container);
  $dispatcher
    ->addListenerService('onEvent', array(
    'service.listener',
    'onEvent',
  ));
  $dispatcher
    ->dispatch('onEvent', $event);
}