function DrupalHTTPRequestTestCase::testDrupalHTTPRequestBasicAuth

File

modules/simpletest/tests/common.test, line 1215

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.