function DrupalHTTPRequestTestCase::testDrupalHTTPRequestHeaders

7.x common.test DrupalHTTPRequestTestCase::testDrupalHTTPRequestHeaders()

Tests Content-language headers generated by Drupal.

File

drupal-7.x/modules/simpletest/tests/common.test, line 1071
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.');
}