Provide less state in getRequestFormat
This commit is contained in:
parent
5898ec2c5e
commit
1d43007f3c
@ -1382,10 +1382,10 @@ class Request
|
||||
public function getRequestFormat($default = 'html')
|
||||
{
|
||||
if (null === $this->format) {
|
||||
$this->format = $this->get('_format', $default);
|
||||
$this->format = $this->get('_format');
|
||||
}
|
||||
|
||||
return $this->format;
|
||||
return null === $this->format ? $default : $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1401,6 +1401,11 @@ class RequestTest extends TestCase
|
||||
$request = new Request();
|
||||
$this->assertEquals('html', $request->getRequestFormat());
|
||||
|
||||
// Ensure that setting different default values over time is possible,
|
||||
// aka. setRequestFormat determines the state.
|
||||
$this->assertEquals('json', $request->getRequestFormat('json'));
|
||||
$this->assertEquals('html', $request->getRequestFormat('html'));
|
||||
|
||||
$request = new Request();
|
||||
$this->assertNull($request->getRequestFormat(null));
|
||||
|
||||
|
Reference in New Issue
Block a user