Skip to content

Instantly share code, notes, and snippets.

@kerihenare
Created September 27, 2012 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerihenare/3791883 to your computer and use it in GitHub Desktop.
Save kerihenare/3791883 to your computer and use it in GitHub Desktop.
Symfony 2.0 HttpFoundation Request::splitHttpAcceptHeader test
<?php
namespace Symfony\Tests\Component\HttpFoundation;
use Symfony\Component\HttpFoundation\Request;
class SplitHttpAcceptHeaderTest extends \PHPUnit_Framework_TestCase
{
public function testHttpAcceptHeaders()
{
$values = array(
'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6',
'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'application/vnd.wap.wmlscriptc, text/vnd.wap.wml, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html, multipart/mixed, */*',
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'zh, en-us; q=0.8, en; q=0.6',
'zh, en-us, en'
);
$results = array(
array('ISO-8859-1', 'US-ASCII', 'UTF-8', 'ISO-10646-UCS-2'),
array('ISO-8859-1', 'utf-8', '*'),
array('application/vnd.wap.wmlscriptc', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/xhtml+xml', 'text/html', 'multipart/mixed', '*/*'),
array('text/html', 'application/xhtml+xml', 'application/xml', '*/*'),
array('zh', 'en-us', 'en'),
array('zh', 'en-us', 'en')
);
$request = new Request();
foreach ($values as $i => $value) {
$this->assertEquals($results[$i], array_keys($request->splitHttpAcceptHeader($value)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment