* * 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:----CFKwYXpZz+tdmEtuUQVt28rv7RHczcmESJUFu1EcLV9HtccTcW5PFnWVRk8rTsG12B7NOEGTNqxg4yhXXCf+l5ibV/j6lknElzE7goDjAVTwra2kNVBNel9EyUv0k9TsqC0VF897quCSWEbl/jUTonvj5wNym4YA2MKs1shtePnZ1wAkStdLXkM6ULNFTNY/eeyJRN6GvkXgs7B8glaMgkM+Xh5At7LRbMj8LJn5Vz+wYwdzlSEuCYxi/Yk0qQaTndAMDOJGnr39fKkuYoc8eKGr0v/eK/X01LiWT3b+EDi7Gqk2wdDd6VI0y3vM6HPlMLsGQuTBNZS1YJ6b/b8vjHVOCcYsJqDJL1lgZ6ahrU6TS+GICTf+N3By/wvZkR+12wBuu9hakxNIGN5WEFYBdr9mhdel8xvbx+gAafwkreIcV/g9mS4AO+Z9ovFQIg4c3eFPTSDX630+2ruUD6vd4g2529yGZRg/LLz80cuErQ8noGf/onscIozpz3MTziMt+mp0Nj3XgVycPk9hypn6ZcsR0TP28bPunsVH2aUuXw43/1Sv7OzisFs9ZtO7cKewu+YLwkozSv39UiyvN9qI2LW0kr9uRG5W1RhguU+OQGPOgb6svQ6yGidiq/VvysWyqAVT9bIcyMFymItKED7glMBMrBUSHaROknx69WfWCas=----ATTACHMENT:----NDQwMzYwMjQ3ODk5MjUyNyAxMzAzMzU1MTE0NTc0Nzg0IDU4NTY1NDE3MDk3MzIzNDM=