You are here

public function ContainerAwareEventDispatcherTest::testAddASubscriberService in Zircon Profile 8

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

File

vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php, line 50

Class

ContainerAwareEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

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