You are here

public function HookEventDispatcherManagerTest::testEventDispatcher in Hook Event Dispatcher 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/Manager/HookEventDispatcherManagerTest.php \Drupal\Tests\hook_event_dispatcher\Unit\Manager\HookEventDispatcherManagerTest::testEventDispatcher()
  2. 3.x tests/src/Unit/Manager/HookEventDispatcherManagerTest.php \Drupal\Tests\hook_event_dispatcher\Unit\Manager\HookEventDispatcherManagerTest::testEventDispatcher()

Test event dispatcher.

File

tests/src/Unit/Manager/HookEventDispatcherManagerTest.php, line 21

Class

HookEventDispatcherManagerTest
Class HookEventDispatcherManagerTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Manager

Code

public function testEventDispatcher() {
  $event = new FakeEvent('test');
  $dispatcher = $this
    ->createMock(EventDispatcherInterface::class);
  $dispatcher
    ->method('dispatch')
    ->with('test', $event)
    ->willReturn($event);
  $manager = new HookEventDispatcherManager($dispatcher);
  $returnedEvent = $manager
    ->register($event);
  self::assertEquals($event, $returnedEvent);
}