public function ContainerAwareEventDispatcherTest::testReEnteringAScope in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php \Symfony\Component\EventDispatcher\Tests\ContainerAwareEventDispatcherTest::testReEnteringAScope()
File
- vendor/
symfony/ event-dispatcher/ Tests/ ContainerAwareEventDispatcherTest.php, line 114
Class
Namespace
Symfony\Component\EventDispatcher\TestsCode
public function testReEnteringAScope() {
$event = new Event();
$service1 = $this
->getMock('Symfony\\Component\\EventDispatcher\\Tests\\Service');
$service1
->expects($this
->exactly(2))
->method('onEvent')
->with($event);
$scope = new Scope('scope');
$container = new Container();
$container
->addScope($scope);
$container
->enterScope('scope');
$container
->set('service.listener', $service1, 'scope');
$dispatcher = new ContainerAwareEventDispatcher($container);
$dispatcher
->addListenerService('onEvent', array(
'service.listener',
'onEvent',
));
$dispatcher
->dispatch('onEvent', $event);
$service2 = $this
->getMock('Symfony\\Component\\EventDispatcher\\Tests\\Service');
$service2
->expects($this
->once())
->method('onEvent')
->with($event);
$container
->enterScope('scope');
$container
->set('service.listener', $service2, 'scope');
$dispatcher
->dispatch('onEvent', $event);
$container
->leaveScope('scope');
$dispatcher
->dispatch('onEvent');
}