public function EventDispatcherTraitTest::test in Feeds 8.3
@covers ::getEventDispatcher @covers ::dispatchEvent
File
- tests/
src/ Unit/ Event/ EventDispatcherTraitTest.php, line 19
Class
- EventDispatcherTraitTest
- @coversDefaultClass \Drupal\feeds\Event\EventDispatcherTrait @group feeds
Namespace
Drupal\Tests\feeds\Unit\EventCode
public function test() {
$mock = $this
->getMockForTrait('Drupal\\feeds\\Event\\EventDispatcherTrait');
$dispatcher = $this
->createMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$container = new ContainerBuilder();
$container
->set('event_dispatcher', $dispatcher);
\Drupal::setContainer($container);
$method = $this
->getMethod(get_class($mock), 'getEventDispatcher');
$this
->assertSame($dispatcher, $method
->invokeArgs($mock, []));
$mock
->setEventDispatcher($dispatcher);
$this
->assertSame($dispatcher, $method
->invokeArgs($mock, []));
$event = new Event();
$dispatcher
->expects($this
->once())
->method('dispatch')
->with('test_event', $event);
$method = $this
->getMethod(get_class($mock), 'dispatchEvent');
$method
->invokeArgs($mock, [
'test_event',
$event,
]);
}