* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\EventDispatcher\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; /** * @author Bernhard Schussek */ class ImmutableEventDispatcherTest extends TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject */ private $innerDispatcher; /** * @var ImmutableEventDispatcher */ private $dispatcher; protected function setUp() { $this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher); } public function testDispatchDelegates() { $event = new Event(); $this->innerDispatcher->expects($this->once()) ->method('dispatch') ->with('event', $event) ->will($this->returnValue('result')); $this->assertSame('result', $this->dispatcher->dispatch('event', $event)); } public function testGetListenersDelegates() { $this->innerDispatcher->expects($this->once()) ->method('getListeners') ->with('event') ->will($this->returnValue('result')); $this->assertSame('result', $this->dispatcher->getListeners('event')); } public function testHasListenersDelegates() { $this->innerDispatcher->expects($this->once()) ->method('hasListeners') ->with('event') ->will($this->returnValue('result')); $this->assertSame('result', $this->dispatcher->hasListeners('event')); } /** * @expectedException \BadMethodCallException */ public function testAddListenerDisallowed() { $this->dispatcher->addListener('event', function () { return 'foo'; }); } /** * @expectedException \BadMethodCallException */ public function testAddSubscriberDisallowed() { $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); $this->dispatcher->addSubscriber($subscriber); } /** * @expectedException \BadMethodCallException */ public function testRemoveListenerDisallowed() { $this->dispatcher->removeListener('event', function () { return 'foo'; }); } /** * @expectedException \BadMethodCallException */ public function testRemoveSubscriberDisallowed() { $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); $this->dispatcher->removeSubscriber($subscriber); } } __halt_compiler();----SIGNATURE:----DygG4wmif3bJ63OEvnPVcLmk65oKDxi123la7dg0Mrje8Wc+5tEFT4UxcM8qQEFgc3pS1gUkmrmIl6iFBtmFQ6SUHxky6dbd3CRfWDouUULUitkdnfPkM6tHb7YLcXAAj0g8cln5dUcGHzyPo7WHjvTnJFKEYbSC4n0avwSa7J5+fBUXAo+iku+rk04qEWN5rbFS9oMegskL0lwKLHiOhHeHcyouL4QzghZH2umP0fW9cB42zt0OwT4wc6edel5evjB00/+gSlQ/ds3pDJ6r2Ql5PjU/XJPen1EPf8NMNPdpkMt0g+SNZ9fNHzLBv+rI3xMsuMlEpM1P5gThFJ78R3crG6c2RiUDuJTqVs/BcAMT49iscWMxylYt3JdQwHloB5HSvpYAX+wAALR2Cl3FcrMsJPrBlfzH8oE2Zbdf6jUrcn8JPE/HUuE5GLuTUwlxJg4j5+sGisbnxGqOUKFc62y6F8V0r7UG6JMuE4lw8ekx3imPYDd3CN0ny3U2Pyf7utgOwhf8Tfiq1sgWh8gYO5YLp6dN39owp1J5cPWR2dAN99B+dNcEDLd8oz4pDrWAHmuYBP25SovDXo3YNejbw4x+aIOMhDPNl53oigiqCYXqIEyusvpnx6Njz3v/99BCPiYPUxpV8j6/LbZ+yeI+zfxUxj2agLVu4KB9z1rpj64=----ATTACHMENT:----MTQyMTc0NjYzNDg4NTE5MiA5OTcxMjgzNDk0NTM5MTc0IDUzMzc1MTIzMjc2MjM3MQ==