public testForcesContentNegotiationOnErrorModelsWhenResourceIsAnImage ( $routeName ) |
public function testForcesContentNegotiationOnErrorModelsWhenResourceIsAnImage($routeName)
{
$route = new Route();
$route->setName($routeName);
$requestHeaders = $this->getMock('Symfony\\Component\\HttpFoundation\\HeaderBag');
$requestHeaders->expects($this->once())->method('get')->with('Accept', '*/*')->will($this->returnValue('*/*'));
$this->request->headers = $requestHeaders;
$this->request->expects($this->once())->method('getExtension')->will($this->returnValue('jpg'));
$this->request->expects($this->once())->method('getRoute')->will($this->returnValue($route));
$this->response->expects($this->once())->method('setVary')->with('Accept');
$this->response->expects($this->once())->method('getModel')->will($this->returnValue($this->getMock('Imbo\\Model\\Error')));
$this->contentNegotiation->expects($this->any())->method('isAcceptable')->will($this->returnValue(1));
$this->responseFormatter->negotiate($this->event);
$this->assertSame('json', $this->responseFormatter->getFormatter());
}