You are here

public function RequestTest::testGetPreferredLanguage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/RequestTest.php \Symfony\Component\HttpFoundation\Tests\RequestTest::testGetPreferredLanguage()

File

vendor/symfony/http-foundation/Tests/RequestTest.php, line 1224

Class

RequestTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testGetPreferredLanguage() {
  $request = new Request();
  $this
    ->assertNull($request
    ->getPreferredLanguage());
  $this
    ->assertNull($request
    ->getPreferredLanguage(array()));
  $this
    ->assertEquals('fr', $request
    ->getPreferredLanguage(array(
    'fr',
  )));
  $this
    ->assertEquals('fr', $request
    ->getPreferredLanguage(array(
    'fr',
    'en',
  )));
  $this
    ->assertEquals('en', $request
    ->getPreferredLanguage(array(
    'en',
    'fr',
  )));
  $this
    ->assertEquals('fr-ch', $request
    ->getPreferredLanguage(array(
    'fr-ch',
    'fr-fr',
  )));
  $request = new Request();
  $request->headers
    ->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
  $this
    ->assertEquals('en', $request
    ->getPreferredLanguage(array(
    'en',
    'en-us',
  )));
  $request = new Request();
  $request->headers
    ->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
  $this
    ->assertEquals('en', $request
    ->getPreferredLanguage(array(
    'fr',
    'en',
  )));
  $request = new Request();
  $request->headers
    ->set('Accept-language', 'zh, en-us; q=0.8');
  $this
    ->assertEquals('en', $request
    ->getPreferredLanguage(array(
    'fr',
    'en',
  )));
  $request = new Request();
  $request->headers
    ->set('Accept-language', 'zh, en-us; q=0.8, fr-fr; q=0.6, fr; q=0.5');
  $this
    ->assertEquals('en', $request
    ->getPreferredLanguage(array(
    'fr',
    'en',
  )));
}