You are here

public function ContainerAwareEventDispatcherTest::testGetListenerPriorityWithServices 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::testGetListenerPriorityWithServices()
  2. 9 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testGetListenerPriorityWithServices()

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testGetListenerPriorityWithServices() {
  $container = new ContainerBuilder();
  $container
    ->register('listener_service', TestEventListener::class);
  $listeners = [
    'test_event' => [
      5 => [
        [
          'service' => [
            'listener_service',
            'preFoo',
          ],
        ],
      ],
    ],
  ];
  $dispatcher = new ContainerAwareEventDispatcher($container, $listeners);
  $listenerService = $container
    ->get('listener_service');
  $actualPriority = $dispatcher
    ->getListenerPriority('test_event', [
    $listenerService,
    'preFoo',
  ]);
  $this
    ->assertSame(5, $actualPriority);
}