You are here

public function ContainerAwareEventDispatcherTest::testPriorityFindsLazyListeners in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testPriorityFindsLazyListeners()
  2. 9 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testPriorityFindsLazyListeners()

File

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

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',
  ]));
}