public function ContainerAwareEventDispatcherTest::testAddSubscriberWithPriorities in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testAddSubscriberWithPriorities()
File
- core/
tests/ Drupal/ Tests/ Component/ EventDispatcher/ ContainerAwareEventDispatcherTest.php, line 407
Class
- ContainerAwareEventDispatcherTest
- Unit tests for the ContainerAwareEventDispatcher.
Namespace
Drupal\Tests\Component\EventDispatcherCode
public function testAddSubscriberWithPriorities() {
$eventSubscriber = new TestEventSubscriber();
$this->dispatcher
->addSubscriber($eventSubscriber);
$eventSubscriber = new TestEventSubscriberWithPriorities();
$this->dispatcher
->addSubscriber($eventSubscriber);
$listeners = $this->dispatcher
->getListeners('pre.foo');
$this
->assertTrue($this->dispatcher
->hasListeners(self::PREFOO));
$this
->assertCount(2, $listeners);
$this
->assertInstanceOf(TestEventSubscriberWithPriorities::class, $listeners[0][0]);
}