function HttpRequestTest::testDrupalHTTPRequestHeaders

Tests Content-language headers generated by Drupal.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/HttpRequestTest.php, line 140
Definition of Drupal\system\Tests\Common\HttpRequestTest.

Class

HttpRequestTest
Tests drupal_http_request().

Namespace

Drupal\system\Tests\Common

Code

function testDrupalHTTPRequestHeaders() {

  // Check the default header.
  $request = drupal_http_request(url('<front>', array(
    'absolute' => TRUE,
  )));
  $this
    ->assertEqual($request->headers['content-language'], 'en', 'Content-Language HTTP header is English.');

  // Add French language.
  $language = new Language(array(
    'langcode' => 'fr',
    'name' => 'French',
  ));
  language_save($language);

  // Request front page in French and check for matching Content-language.
  $request = drupal_http_request(url('<front>', array(
    'absolute' => TRUE,
    'language' => $language,
  )));
  $this
    ->assertEqual($request->headers['content-language'], 'fr', 'Content-Language HTTP header is French.');
}