public function RequestTest::testGetLanguages in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Tests/RequestTest.php \Symfony\Component\HttpFoundation\Tests\RequestTest::testGetLanguages()
File
- vendor/
symfony/ http-foundation/ Tests/ RequestTest.php, line 1328
Class
Namespace
Symfony\Component\HttpFoundation\TestsCode
public function testGetLanguages() {
$request = new Request();
$this
->assertEquals(array(), $request
->getLanguages());
$request = new Request();
$request->headers
->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
$this
->assertEquals(array(
'zh',
'en_US',
'en',
), $request
->getLanguages());
$this
->assertEquals(array(
'zh',
'en_US',
'en',
), $request
->getLanguages());
$request = new Request();
$request->headers
->set('Accept-language', 'zh, en-us; q=0.6, en; q=0.8');
$this
->assertEquals(array(
'zh',
'en',
'en_US',
), $request
->getLanguages());
// Test out of order qvalues
$request = new Request();
$request->headers
->set('Accept-language', 'zh, en, en-us');
$this
->assertEquals(array(
'zh',
'en',
'en_US',
), $request
->getLanguages());
// Test equal weighting without qvalues
$request = new Request();
$request->headers
->set('Accept-language', 'zh; q=0.6, en, en-us; q=0.6');
$this
->assertEquals(array(
'en',
'zh',
'en_US',
), $request
->getLanguages());
// Test equal weighting with qvalues
$request = new Request();
$request->headers
->set('Accept-language', 'zh, i-cherokee; q=0.6');
$this
->assertEquals(array(
'zh',
'cherokee',
), $request
->getLanguages());
}