You are here

function DrupalHTTPRequestTestCase::testDrupalHTTPRequestBasicAuth in Drupal 7

File

modules/simpletest/tests/common.test, line 1165
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('://', '://' . $username . ':' . $password . '@', $url);
  $result = drupal_http_request($auth);
  $this
    ->drupalSetContent($result->data);
  $this
    ->assertRaw($username, 'Username is passed correctly.');
  $this
    ->assertRaw($password, 'Password is passed correctly.');
}