You are here

function DrupalHTTPRequestTestCase::testDrupalHTTPRequestBasicAuth in SimpleTest 7

File

tests/common.test, line 797
Tests for common.inc functionality.

Class

DrupalHTTPRequestTestCase
Test drupal_http_request().

Code

function testDrupalHTTPRequestBasicAuth() {
  $username = $this
    ->randomName();
  $password = $this
    ->randomName();
  $url = url('system-test/auth', array(
    'absolute' => TRUE,
  ));
  $auth = str_replace('http://', 'http://' . $username . ':' . $password . '@', $url);
  $result = drupal_http_request($auth);
  $this
    ->drupalSetContent($result->data);
  $this
    ->assertRaw($username, t('$_SERVER["PHP_AUTH_USER"] is passed correctly.'));
  $this
    ->assertRaw($password, t('$_SERVER["PHP_AUTH_PW"] is passed correctly.'));
}