public function EventDispatcherTest::testDispatchForClosure

File

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

Class

EventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

public function testDispatchForClosure() {
  $invoked = 0;
  $listener = function () use (&$invoked) {
    $invoked++;
  };
  $this->dispatcher
    ->addListener('pre.foo', $listener);
  $this->dispatcher
    ->addListener('post.foo', $listener);
  $this->dispatcher
    ->dispatch(self::preFoo);
  $this
    ->assertEquals(1, $invoked);
}