14 use PHPUnit\Framework\TestCase;
21 class ImmutableEventDispatcherTest
extends TestCase
26 private $innerDispatcher;
33 protected function setUp()
35 $this->innerDispatcher = $this->getMockBuilder(
'Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
36 $this->dispatcher =
new ImmutableEventDispatcher($this->innerDispatcher);
43 $this->innerDispatcher->expects($this->once())
45 ->with(
'event', $event)
46 ->will($this->returnValue(
'result'));
48 $this->assertSame(
'result', $this->dispatcher->dispatch(
'event', $event));
53 $this->innerDispatcher->expects($this->once())
54 ->method(
'getListeners')
56 ->will($this->returnValue(
'result'));
58 $this->assertSame(
'result', $this->dispatcher->getListeners(
'event'));
63 $this->innerDispatcher->expects($this->once())
64 ->method(
'hasListeners')
66 ->will($this->returnValue(
'result'));
68 $this->assertSame(
'result', $this->dispatcher->hasListeners(
'event'));
76 $this->dispatcher->addListener(
'event',
function () {
return 'foo'; });
84 $subscriber = $this->getMockBuilder(
'Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
86 $this->dispatcher->addSubscriber($subscriber);
94 $this->dispatcher->removeListener(
'event',
function () {
return 'foo'; });
102 $subscriber = $this->getMockBuilder(
'Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
104 $this->dispatcher->removeSubscriber($subscriber);