1.20.x user.test | UserPictureTestCase::testWithGDinvalidDimension() |
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/ tests/ user.test, line 1020 - Tests for user.module.
Class
Code
function testWithGDinvalidDimension() {
if ($this->_directory_test && image_get_toolkit()) {
$this->backdropLogin($this->user);
$image = current($this->backdropGetTestFiles('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);
config('system.core')
->set('user_picture_dimensions', $test_dim)
->set('user_picture_file_size', 0)
->save();
$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' => user_format_name($this->user)));
$style = config_get('system.core', 'user_picture_style');
$this->assertRaw(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");
}
}