* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\KernelEvents; /** * Test AddRequestFormatsListener class. * * @author Gildas Quemener */ class AddRequestFormatsListenerTest extends TestCase { /** * @var AddRequestFormatsListener */ private $listener; protected function setUp() { $this->listener = new AddRequestFormatsListener(array('csv' => array('text/csv', 'text/plain'))); } protected function tearDown() { $this->listener = null; } public function testIsAnEventSubscriber() { $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); } public function testRegisteredEvent() { $this->assertEquals( array(KernelEvents::REQUEST => array('onKernelRequest', 1)), AddRequestFormatsListener::getSubscribedEvents() ); } public function testSetAdditionalFormats() { $request = $this->getRequestMock(); $event = $this->getGetResponseEventMock($request); $request->expects($this->once()) ->method('setFormat') ->with('csv', array('text/csv', 'text/plain')); $this->listener->onKernelRequest($event); } protected function getRequestMock() { return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); } protected function getGetResponseEventMock(Request $request) { $event = $this ->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); $event->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)); return $event; } } __halt_compiler();----SIGNATURE:----AdhSu5lpwDbHK7pVTOFytFx1UwxFtTacvVjSHLOSja+fnr4WndDJmdi7q9LLebcFYT/ik4izhvzAQsgw8FpUiqRgGww85QIDbwYPnS59vUoi4sWPNqJPpxbErqfJbpK35MneEUHnMFjh0vDm6lxS+9ZYOfSTCSJThfSZC7Icc+3Eh9IiUsH1tX0SKj68Pk5SqaKyLRW+3iFAGaCEED/BTsQanL/MiJjRwCCOjYPXBbl2QHqlEm7kcs6zury7CoXpkhhun9YjUYN9AdmZw+TY6lvl13mA6ycrrGVzw6lsB9YI6Qt4JUkiboFidBy4js4vo6rQQ8GbMNjZDhjvEU1slF9hDRmmjvsT4Cnzx3+0Hk/Cr2/ZLBiGqI5R4M9oQAon69ZMgQ+JWJjGVtEYPWDge9aV1nHBTGHxVCPfjnUUcWU4CF6GO6k3tyuxyCVT/hHc4f57K80YzWqQywWJoWz3B+9G8E/0mS+9amzxTn1JcatNaWWakXtRlgD0TAAdNeo3s3X0G1lQ2qJupD9jlNWmwg20m2nHuZv64CVZJWm3sa4yomgg6VcJ/V28kMqSwxozu865PIciH9qSVBwSvOZjqK1X1OHxmEBL/m7n5BAok1H8GCRI0k+UTQp3JgF75VWsOknXx+bMdUaIQyA/tQ3lJ4qmdpQRa8VaJcVJKeMnjM4=----ATTACHMENT:----MTAyODA2MzU1NzE2MTgyIDQyNDU4OTMxMjQxOTA1NjUgMjIxOTU3ODg0NTM1MTYx