function UserPictureTestCase::testPictureIsValid
7.x user.test | UserPictureTestCase::testPictureIsValid() |
Do the test: Picture is valid (proper size and dimension)
results: The image should be uploaded
File
- drupal-7.x/
modules/ user/ user.test, line 1103 - Tests for user.module.
Class
Code
function testPictureIsValid() {
if ($this->_directory_test) {
$this->drupalLogin($this->user);
$image = current($this->drupalGetTestFiles('image'));
$info = image_get_info($image->uri);
// Set new variables: valid 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 if image is displayed in user's profile page.
$this->drupalGet('user');
$this->assertRaw(file_uri_target($pic_path), "Image is displayed in user's profile page");
// Check if file is located in proper directory.
$this->assertTrue(is_file($pic_path), 'File is located in proper directory');
// Set new picture dimensions.
$test_dim = ($info['width'] + 5) . 'x' . ($info['height'] + 5);
variable_set('user_picture_dimensions', $test_dim);
$pic_path2 = $this->saveUserPicture($image);
$this->assertNotEqual($pic_path, $pic_path2, 'Filename of second picture is different.');
}
}