public function ContainerAwareEventDispatcherTest::testGetListenersWithCallables in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest::testGetListenersWithCallables()
File
- core/
tests/ Drupal/ Tests/ Component/ EventDispatcher/ ContainerAwareEventDispatcherTest.php, line 39 - Contains \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest.
Class
- ContainerAwareEventDispatcherTest
- Unit tests for the ContainerAwareEventDispatcher.
Namespace
Drupal\Tests\Component\EventDispatcherCode
public function testGetListenersWithCallables() {
// When passing in callables exclusively as listeners into the event
// dispatcher constructor, the event dispatcher must not attempt to
// resolve any services.
$container = $this
->getMock('Symfony\\Component\\DependencyInjection\\IntrospectableContainerInterface');
$container
->expects($this
->never())
->method($this
->anything());
$firstListener = new CallableClass();
$secondListener = function () {
};
$thirdListener = array(
new TestEventListener(),
'preFoo',
);
$listeners = array(
'test_event' => array(
0 => array(
array(
'callable' => $firstListener,
),
array(
'callable' => $secondListener,
),
array(
'callable' => $thirdListener,
),
),
),
);
$dispatcher = new ContainerAwareEventDispatcher($container, $listeners);
$actualListeners = $dispatcher
->getListeners();
$expectedListeners = array(
'test_event' => array(
$firstListener,
$secondListener,
$thirdListener,
),
);
$this
->assertSame($expectedListeners, $actualListeners);
}