1 user.test UserPictureTestCase::testExternalPicture()

Test HTTP schema working with user pictures.

File

core/modules/user/tests/user.test, line 1307
Tests for user.module.

Class

UserPictureTestCase

Code

function testExternalPicture() {
  $this->backdropLogin($this->user);
  // Set the default picture to an URI with a HTTP schema.
  $images = $this->backdropGetTestFiles('image');
  $image = $images[0];
  $pic_path = file_create_url($image->uri);
  config_set('system.core', 'user_picture_default', $pic_path);

  // Check if image is displayed in user's profile page.
  $this->backdropGet('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: " . $pic_path . " " . print_r($elements, TRUE));
}