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

File

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