use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
+use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
}
/**
+ * @group legacy
* @dataProvider getStatusCodes
*/
- public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode, $expectedStatusCode)
+ public function testLegacyHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode, $expectedStatusCode)
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode, $expectedStatusCode) {
);
}
+ /**
+ * @dataProvider getSpecificStatusCodes
+ */
+ public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($expectedStatusCode)
+ {
+ $dispatcher = new EventDispatcher();
+ $dispatcher->addListener(KernelEvents::EXCEPTION, function (GetResponseForExceptionEvent $event) use ($expectedStatusCode) {
+ $event->allowCustomResponseCode();
+ $event->setResponse(new Response('', $expectedStatusCode));
+ });
+
+ $kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException(); });
+ $response = $kernel->handle(new Request());
+
+ $this->assertEquals($expectedStatusCode, $response->getStatusCode());
+ }
+
+ public function getSpecificStatusCodes()
+ {
+ return array(
+ array(200),
+ array(302),
+ array(403),
+ );
+ }
+
public function testHandleWhenAListenerReturnsAResponse()
{
$dispatcher = new EventDispatcher();
public function testInconsistentClientIpsOnMasterRequests()
{
$request = new Request();
- $request->setTrustedProxies(array('1.1.1.1'), -1);
+ $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED);
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$request->headers->set('FORWARDED', 'for=2.2.2.2');
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');