[HttpFoundation] fixed format duplication in Request
This commit is contained in:
parent
dc762e10d7
commit
8c2a733528
@ -406,9 +406,8 @@ class Request
|
|||||||
$dup->method = null;
|
$dup->method = null;
|
||||||
$dup->format = null;
|
$dup->format = null;
|
||||||
|
|
||||||
if (!$dup->get('_format')) {
|
if (!$dup->get('_format') && $this->get('_format')) {
|
||||||
// we set the request format to null if the current request is not known
|
$dup->attributes->set('_format', $this->get('_format'));
|
||||||
$dup->setRequestFormat($this->getRequestFormat(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dup;
|
return $dup;
|
||||||
|
@ -259,9 +259,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('foo=bar', $request->getQueryString());
|
$this->assertEquals('foo=bar', $request->getQueryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Symfony\Component\HttpFoundation\Request::duplicate
|
|
||||||
*/
|
|
||||||
public function testDuplicate()
|
public function testDuplicate()
|
||||||
{
|
{
|
||||||
$request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar'));
|
$request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar'));
|
||||||
@ -280,6 +277,15 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided');
|
$this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDuplicateWithFormat()
|
||||||
|
{
|
||||||
|
$request = new Request(array(), array(), array('_format' => 'json'));
|
||||||
|
$dup = $request->duplicate();
|
||||||
|
|
||||||
|
$this->assertEquals('json', $dup->getRequestFormat());
|
||||||
|
$this->assertEquals('json', $dup->attributes->get('_format'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Symfony\Component\HttpFoundation\Request::getFormat
|
* @covers Symfony\Component\HttpFoundation\Request::getFormat
|
||||||
* @covers Symfony\Component\HttpFoundation\Request::setFormat
|
* @covers Symfony\Component\HttpFoundation\Request::setFormat
|
||||||
|
Reference in New Issue
Block a user