function 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.