You are here

public function TraceableEventDispatcherTest::testAddRemoveListener in Zircon Profile 8

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

File

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

Class

TraceableEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests\Debug

Code

public function testAddRemoveListener() {
  $dispatcher = new EventDispatcher();
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
  $tdispatcher
    ->addListener('foo', $listener = function () {
  });
  $listeners = $dispatcher
    ->getListeners('foo');
  $this
    ->assertCount(1, $listeners);
  $this
    ->assertSame($listener, $listeners[0]);
  $tdispatcher
    ->removeListener('foo', $listener);
  $this
    ->assertCount(0, $dispatcher
    ->getListeners('foo'));
}