function ContainerAwareEventDispatcherTest::testDispatchForClosure

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchForClosure()
  2. 10 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchForClosure()
  3. 11.x core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchForClosure()

File

core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php, line 300

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.