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