| 7 user.test | UserPictureTestCase::testWithoutGDinvalidSize() |
| 8 user.test | UserPictureTestCase::testWithoutGDinvalidSize() |
Do the test: GD Toolkit is not installed Picture has invalid size
results: The image shouldn't be uploaded
File
- modules/
user/ user.test, line 1001 - Tests for user.module.
Code
function testWithoutGDinvalidSize() {
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: valid dimensions, invalid filesize.
$test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10);
$test_size = 1;
variable_set('user_picture_dimensions', $test_dim);
variable_set('user_picture_file_size', $test_size);
$pic_path = $this->saveUserPicture($image);
// Test that the upload failed and that the correct reason was cited.
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
$this->assertRaw($text, t('Upload failed.'));
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->uri)), '%maxsize' => format_size($test_size * 1024)));
$this->assertRaw($text, t('File size cited as reason for failure.'));
// Check if file is not uploaded.
$this->assertFalse(is_file($pic_path), t('File was not uploaded.'));
}
}
Login or register to post comments