You are here

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

File

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

Class

ContainerAwareEventDispatcherTest
Unit tests for the ContainerAwareEventDispatcher.

Namespace

Drupal\Tests\Component\EventDispatcher

Code

public function testEventReceivesTheDispatcherInstanceAsArgument() {
  $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);
}