You are here

public function TraceableEventDispatcherTest::testGetCalledListeners 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::testGetCalledListeners()

File

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

Class

TraceableEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests\Debug

Code

public function testGetCalledListeners() {
  $dispatcher = new EventDispatcher();
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
  $tdispatcher
    ->addListener('foo', $listener = function () {
  });
  $this
    ->assertEquals(array(), $tdispatcher
    ->getCalledListeners());
  $this
    ->assertEquals(array(
    'foo.closure' => array(
      'event' => 'foo',
      'type' => 'Closure',
      'pretty' => 'closure',
    ),
  ), $tdispatcher
    ->getNotCalledListeners());
  $tdispatcher
    ->dispatch('foo');
  $this
    ->assertEquals(array(
    'foo.closure' => array(
      'event' => 'foo',
      'type' => 'Closure',
      'pretty' => 'closure',
    ),
  ), $tdispatcher
    ->getCalledListeners());
  $this
    ->assertEquals(array(), $tdispatcher
    ->getNotCalledListeners());
}