function ContainerAwareEventDispatcherTest::testEventReceivesTheDispatcherInstanceAsArgument

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

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testEventReceivesTheDispatcherInstanceAsArgument() : void {
    $listener = new TestWithDispatcher();
    $this->dispatcher
        ->addListener('test', [
        $listener,
        'foo',
    ]);
    $this->assertNull($listener->name);
    $this->assertNull($listener->dispatcher);
    $this->dispatcher
        ->dispatch(new Event(), 'test');
    $this->assertEquals('test', $listener->name);
    $this->assertSame($this->dispatcher, $listener->dispatcher);
}

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