|
@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
|
|
-use Symfony\Component\HttpKernel\CoreEvents;
|
|
|
+use Symfony\Component\HttpKernel\KernelEvents;
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
|
|
|
|
|
class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
@@ -29,7 +29,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
$this->dispatcher = new EventDispatcher();
|
|
|
$listener = new ResponseListener('UTF-8');
|
|
|
- $this->dispatcher->addListener(CoreEvents::RESPONSE, array($listener, 'onCoreResponse'));
|
|
|
+ $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'));
|
|
|
|
|
|
$this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
|
|
|
|
@@ -46,7 +46,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
$response = new Response('foo');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('', $event->getResponse()->headers->get('content-type'));
|
|
|
}
|
|
@@ -57,7 +57,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
$response->headers->set('Content-Type', 'text/plain');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('text/plain', $event->getResponse()->headers->get('content-type'));
|
|
|
}
|
|
@@ -67,7 +67,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
$response = new Response('foo');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('text/html', $event->getResponse()->headers->get('content-type'));
|
|
|
}
|
|
@@ -79,7 +79,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
$request->setRequestFormat('json');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('application/json', $event->getResponse()->headers->get('content-type'));
|
|
|
}
|
|
@@ -90,7 +90,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
$request = Request::create('/', 'HEAD');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('', $response->getContent());
|
|
|
}
|
|
@@ -98,12 +98,12 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
public function testFilterSetsNonDefaultCharsetIfNotOverridden()
|
|
|
{
|
|
|
$listener = new ResponseListener('ISO-8859-15');
|
|
|
- $this->dispatcher->addListener(CoreEvents::RESPONSE, array($listener, 'onCoreResponse'), 1);
|
|
|
+ $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1);
|
|
|
|
|
|
$response = new Response('foo');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('ISO-8859-15', $response->getCharset());
|
|
|
}
|
|
@@ -111,13 +111,13 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
public function testFilterDoesNothingIfCharsetIsOverridden()
|
|
|
{
|
|
|
$listener = new ResponseListener('ISO-8859-15');
|
|
|
- $this->dispatcher->addListener(CoreEvents::RESPONSE, array($listener, 'onCoreResponse'), 1);
|
|
|
+ $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1);
|
|
|
|
|
|
$response = new Response('foo');
|
|
|
$response->setCharset('ISO-8859-1');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('ISO-8859-1', $response->getCharset());
|
|
|
}
|
|
@@ -125,14 +125,14 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|
|
public function testFiltersSetsNonDefaultCharsetIfNotOverriddenOnNonTextContentType()
|
|
|
{
|
|
|
$listener = new ResponseListener('ISO-8859-15');
|
|
|
- $this->dispatcher->addListener(CoreEvents::RESPONSE, array($listener, 'onCoreResponse'), 1);
|
|
|
+ $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1);
|
|
|
|
|
|
$response = new Response('foo');
|
|
|
$request = Request::create('/');
|
|
|
$request->setRequestFormat('application/json');
|
|
|
|
|
|
$event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
|
|
|
- $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
|
|
|
+ $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
|
|
|
|
|
$this->assertEquals('ISO-8859-15', $response->getCharset());
|
|
|
}
|