* * 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:----NvjLER6MKmpnee4OwWG1/nBUZ0BFaV1HOCgmUy66QjkoXkzFA16uB7yDl9y9jwi8EtRF9CcmuL8sHxRVXfi2pUUuOxrymdrSlyagV7J/aRV8PeqWBbRRJe9EMOIkPmc8nZiVb++n0D9cDXH4PEv8lShJJuoUbxsQ3R6RMCF/RV1n9i5uuuLhfq3b1NlUJp0uh4+EGzMsM/mOvAyDjASDglZTOWiQD75BWCyLPKOXx7ylR2lQSwaiJRlFXvB0vrZKATdaN1ip2gr+NpE2aj5doCuIUk3eQx9wRGRcqB2XtMw2/DMVtKI4qdv0EOSiRyIjaQNCS+zSiIKpe310m/+ARkBi0p6EkVJ/T7eIZsbGUrhjSr/i6TbVfyhAG9OxFpQuXyRdDrMI20VIHT3LX4BrOj6ye//PSkCxwsepqv83qLTt/BaClJ5RzuexvKR8tsW5pVvfbP7tEbV7CXHtAHkZlMEbb+NTRdJzqNRWnA/sDkZHKIrYEOCc8bohOJikLnj0vba408khG3QaBifhJUBFIBU1eiJYUZbt+hIK+Gw24poSEQ4pvCTL/YPe0rvVzoRjHLkeVqXMh/72k7MVEF96L01y4YbYuN3Mt7WPkWI1Na5wtaW4n5+pds9chnyOS/ihUZ04rF8ZEdTMc+ld7Ww4FDaiFUag0P1ouw040Vg593c=----ATTACHMENT:----NzIzODA2MzkwODY0NzQxOCA5MTMxNjA0MzkzMjgxMzgwIDUwOTE3MjUzMjYxMDA5MTQ=