* * 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:----Y2i2pdzWGOE6+ZO4I2kkUXb4xwvRHG3Qv6Xe3NMpVRS/qAT5b4PBrqlBws5f0Cf8mVNYVzIJf3Tt8YJS+H82TQLn2CGCHWVfq73V327TCPBHTIcFfsCu9A3k+EFgSTDOu9RUL97IvFtyrcCqMmb16wCA7tEil4iL7NeFl7uM8O1KeRqlG6HW9gDfqid+EH5hPKXBkfcHpcjA3o6OOIO8TzZzEMb+MiB1KCe3Sw2mb8V6fBary8AfVO5d5G7HmxnYFXQ7q4ZYtwu/8a7Ij4a8nOT82cPijy+LYvPBxoC9SFn9Vw6oZ0As5Ne5LeFVUtHgOXSs8XCkkAVvZuJD1/zi9ZPtTiaJLAo/HleRugGz1fjgrdgoLEmu11gEqrbm0sWvHcPonY0HQW1DFDyh5UgBJAfLUYcQfwTh7btAq4DzoRRopNW3uI1nubE/4F/VtrlTvKZMk9V0+RI/u47hq2PqIl2XW7dKV9j+z1bm4mGG8aa0n4hpEEMpFOb0wGCC6jJXxwC3REafq5YCOZeTtO9c4HbDAelgiot+oeEEHxvE087LAJQWqBvHutAd9YFwejhY8CzNAG0uyTusikdW99nJLDyHTvEl4jb9nLGxUlBrTtluiwYgvVsEAGawaRYXJUoNDUqhdXSDWUHQ3zpD9ak7n7zDF/yJ8LYW2GFBzAtISkE=----ATTACHMENT:----OTc2OTU2NDY0ODY1ODA2OSA0MTQwNTUzNTA3OTc3MTk0IDIwODAwNzczNjU3OTQyMzA=