| 7 user.test | UserPictureTestCase::testPictureIsValid() |
| 8 user.test | UserPictureTestCase::testPictureIsValid() |
Do the test: Picture is valid (proper size and dimension)
results: The image should be uploaded
File
- modules/
user/ user.test, line 1033 - Tests for user.module.
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), t("Image is displayed in user's profile page"));
// Check if file is located in proper directory.
$this->assertTrue(is_file($pic_path), t('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, t('Filename of second picture is different.'));
}
}
Login or register to post comments