function ContainerAwareEventDispatcherTest::testDispatchByPriority
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchByPriority()
- 10 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchByPriority()
- 11.x core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testDispatchByPriority()
File
-
core/
tests/ Drupal/ Tests/ Component/ EventDispatcher/ ContainerAwareEventDispatcherTest.php, line 380
Class
- ContainerAwareEventDispatcherTest
- Unit tests for the ContainerAwareEventDispatcher.
Namespace
Drupal\Tests\Component\EventDispatcherCode
public function testDispatchByPriority() {
$invoked = [];
$listener1 = function () use (&$invoked) {
$invoked[] = '1';
};
$listener2 = function () use (&$invoked) {
$invoked[] = '2';
};
$listener3 = function () use (&$invoked) {
$invoked[] = '3';
};
$this->dispatcher
->addListener('pre.foo', $listener1, -10);
$this->dispatcher
->addListener('pre.foo', $listener2);
$this->dispatcher
->addListener('pre.foo', $listener3, 10);
$this->dispatcher
->dispatch(new Event(), self::PREFOO);
$this->assertEquals([
'3',
'2',
'1',
], $invoked);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.