public function ContainerAwareEventDispatcherTest::testDispatchForClosure in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchForClosure()
- 9 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchForClosure()
File
- core/
tests/ Drupal/ Tests/ Component/ EventDispatcher/ ContainerAwareEventDispatcherTest.php, line 314
Class
- ContainerAwareEventDispatcherTest
- Unit tests for the ContainerAwareEventDispatcher.
Namespace
Drupal\Tests\Component\EventDispatcherCode
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(new Event(), self::PREFOO);
$this
->assertEquals(1, $invoked);
}