function ContainerAwareEventDispatcherTest::testGetListenerPriority

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

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testGetListenerPriority() {
    $listener1 = new TestEventListener();
    $listener2 = new TestEventListener();
    $this->dispatcher
        ->addListener('pre.foo', $listener1, -10);
    $this->dispatcher
        ->addListener('pre.foo', $listener2);
    $this->assertSame(-10, $this->dispatcher
        ->getListenerPriority('pre.foo', $listener1));
    $this->assertSame(0, $this->dispatcher
        ->getListenerPriority('pre.foo', $listener2));
    $this->assertNull($this->dispatcher
        ->getListenerPriority('pre.bar', $listener2));
    $this->assertNull($this->dispatcher
        ->getListenerPriority('pre.foo', function () {
    }));
}

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