-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[HttpFoundation] Adds getAcceptableFormats() method for Request #26486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1427,6 +1427,16 @@ public function testGetAcceptableContentTypes() | |
| $this->assertEquals(array('application/vnd.wap.wmlscriptc', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/xhtml+xml', 'text/html', 'multipart/mixed', '*/*'), $request->getAcceptableContentTypes()); | ||
| } | ||
|
|
||
| public function testGetAcceptableFormats() | ||
| { | ||
| $request = new Request(); | ||
| $this->assertEquals(array(), $request->getAcceptableFormats()); | ||
|
|
||
| $request = new Request(); | ||
| $request->headers->set('Accept', 'text/html, application/xhtml+xml, application/xml;q=0.9, */*'); | ||
| $this->assertEquals(array('html', 'xml'), $request->getAcceptableFormats()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would it only return html and xml if everything is acceptable according to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't see where I would possibly use this method. What would be useful is a similar method that accepts formats as argument and would return the ones that are acceptable according to the accept header. This would then allow to make use of |
||
| } | ||
|
|
||
| public function testGetLanguages() | ||
| { | ||
| $request = new Request(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is
array_valuesactually required?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is added because the mix of
array_filterandarray_unqiuesometimes returns[0 => 'html', 2 => 'xml', 5 => 'json'].This create problems with tests or confusion when checking the array, so it's best to reset the keys