You are here

function UserPictureTestCase::testExternalPicture in Drupal 7

Test HTTP schema working with user pictures.

File

modules/user/user.test, line 1480
Tests for user.module.

Class

UserPictureTestCase

Code

function testExternalPicture() {
  $this
    ->drupalLogin($this->user);

  // Set the default picture to an URI with a HTTP schema.
  $images = $this
    ->drupalGetTestFiles('image');
  $image = $images[0];
  $pic_path = file_create_url($image->uri);
  variable_set('user_picture_default', $pic_path);

  // Check if image is displayed in user's profile page.
  $this
    ->drupalGet('user');

  // Get the user picture image via xpath.
  $elements = $this
    ->xpath('//div[@class="user-picture"]/img');
  $this
    ->assertEqual(count($elements), 1, "There is exactly one user picture on the user's profile page");
  $this
    ->assertEqual($pic_path, (string) $elements[0]['src'], "User picture source is correct.");
}