You are here

function DrupalHTTPRequestTestCase::testDrupalHTTPRequestHeaders in Drupal 7

Tests Content-language headers generated by Drupal.

File

modules/simpletest/tests/common.test, line 1220
Tests for common.inc functionality.

Class

DrupalHTTPRequestTestCase
Test drupal_http_request().

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 German language and set as default.
  locale_add_language('de', 'German', 'Deutsch', LANGUAGE_LTR, '', '', TRUE, TRUE);

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