You are here

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

File

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

Class

TraceableEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests\Debug

Code

public function testAddRemoveSubscriber() {
  $dispatcher = new EventDispatcher();
  $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
  $subscriber = new EventSubscriber();
  $tdispatcher
    ->addSubscriber($subscriber);
  $listeners = $dispatcher
    ->getListeners('foo');
  $this
    ->assertCount(1, $listeners);
  $this
    ->assertSame(array(
    $subscriber,
    'call',
  ), $listeners[0]);
  $tdispatcher
    ->removeSubscriber($subscriber);
  $this
    ->assertCount(0, $dispatcher
    ->getListeners('foo'));
}