You are here

public function ContainerAwareEventDispatcherTest::testRemoveSubscriber in Drupal 9

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

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testRemoveSubscriber() {
  $eventSubscriber = new TestEventSubscriber();
  $this->dispatcher
    ->addSubscriber($eventSubscriber);
  $this
    ->assertTrue($this->dispatcher
    ->hasListeners(self::PREFOO));
  $this
    ->assertTrue($this->dispatcher
    ->hasListeners(self::POSTFOO));
  $this->dispatcher
    ->removeSubscriber($eventSubscriber);
  $this
    ->assertFalse($this->dispatcher
    ->hasListeners(self::PREFOO));
  $this
    ->assertFalse($this->dispatcher
    ->hasListeners(self::POSTFOO));
}