function ContainerAwareEventDispatcherTest::testGetLazyListeners

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testGetLazyListeners()
  2. 8.9.x core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testGetLazyListeners()
  3. 10 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testGetLazyListeners()

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testGetLazyListeners() {
    $test = new TestWithDispatcher();
    $factory = function () use ($test) {
        return $test;
    };
    $this->dispatcher
        ->addListener('foo', [
        $factory,
        'foo',
    ], 3);
    $this->assertSame([
        [
            $test,
            'foo',
        ],
    ], $this->dispatcher
        ->getListeners('foo'));
    $this->dispatcher
        ->removeListener('foo', [
        $test,
        'foo',
    ]);
    $this->dispatcher
        ->addListener('bar', [
        $factory,
        'foo',
    ], 3);
    $this->assertSame([
        'bar' => [
            [
                $test,
                'foo',
            ],
        ],
    ], $this->dispatcher
        ->getListeners());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.