public function EventDispatcherTest::testAddListener

File

drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php, line 49

Class

EventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

public function testAddListener() {
  $this->dispatcher
    ->addListener('pre.foo', array(
    $this->listener,
    'preFoo',
  ));
  $this->dispatcher
    ->addListener('post.foo', array(
    $this->listener,
    'postFoo',
  ));
  $this
    ->assertTrue($this->dispatcher
    ->hasListeners(self::preFoo));
  $this
    ->assertTrue($this->dispatcher
    ->hasListeners(self::postFoo));
  $this
    ->assertCount(1, $this->dispatcher
    ->getListeners(self::preFoo));
  $this
    ->assertCount(1, $this->dispatcher
    ->getListeners(self::postFoo));
  $this
    ->assertCount(2, $this->dispatcher
    ->getListeners());
}