You are here

public function TraceableEventDispatcherTest::testDispatchCallListeners in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php \Symfony\Component\EventDispatcher\Tests\Debug\TraceableEventDispatcherTest::testDispatchCallListeners()

File

vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php, line 135

Class

TraceableEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests\Debug

Code

public function testDispatchCallListeners() {
  $called = array();
  $dispatcher = new EventDispatcher();
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
  $tdispatcher
    ->addListener('foo', $listener1 = function () use (&$called) {
    $called[] = 'foo1';
  });
  $tdispatcher
    ->addListener('foo', $listener2 = function () use (&$called) {
    $called[] = 'foo2';
  });
  $tdispatcher
    ->dispatch('foo');
  $this
    ->assertEquals(array(
    'foo1',
    'foo2',
  ), $called);
}