function ContainerAwareEventDispatcherTest::testPriorityFindsLazyListeners

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

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testPriorityFindsLazyListeners() {
    $test = new TestWithDispatcher();
    $factory = function () use ($test) {
        return $test;
    };
    $this->dispatcher
        ->addListener('foo', [
        $factory,
        'foo',
    ], 3);
    $this->assertSame(3, $this->dispatcher
        ->getListenerPriority('foo', [
        $test,
        'foo',
    ]));
    $this->dispatcher
        ->removeListener('foo', [
        $factory,
        'foo',
    ]);
    $this->dispatcher
        ->addListener('foo', [
        $test,
        'foo',
    ], 5);
    $this->assertSame(5, $this->dispatcher
        ->getListenerPriority('foo', [
        $factory,
        'foo',
    ]));
}

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