Do the test: GD Toolkit is installed Picture has invalid dimension

results: The image should be uploaded because ImageGDToolkit resizes the picture

File

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

Class

UserPictureTestCase

Code

function testWithGDinvalidDimension() {
  if ($this->_directory_test && image_get_toolkit()) {
    $this
      ->drupalLogin($this->user);
    $image = current($this
      ->drupalGetTestFiles('image'));
    $info = image_get_info($image->uri);

    // Set new variables: invalid dimensions, valid filesize (0 = no limit).
    $test_dim = $info['width'] - 10 . 'x' . ($info['height'] - 10);
    variable_set('user_picture_dimensions', $test_dim);
    variable_set('user_picture_file_size', 0);
    $pic_path = $this
      ->saveUserPicture($image);

    // Check that the image was resized and is being displayed on the
    // user's profile page.
    $text = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array(
      '%dimensions' => $test_dim,
    ));
    $this
      ->assertRaw($text, 'Image was resized.');
    $alt = t("@user's picture", array(
      '@user' => format_username($this->user),
    ));
    $style = variable_get('user_picture_style', '');
    $this
      ->assertRaw(check_plain(image_style_url($style, $pic_path)), "Image is displayed in user's edit page");

    // Check if file is located in proper directory.
    $this
      ->assertTrue(is_file($pic_path), "File is located in proper directory");
  }
}