$errors =
file_validate_is_image($this->nonImage
);
$this->
assertCount(1,
$errors, 'An error reported for our non-image file.'
);
} /**
* This ensures the resolution of a specific file is within bounds.
*
* The image will be resized if it's too large.
*/
public function testFileValidateImageResolution() { // Non-images.
$errors =
file_validate_image_resolution($this->nonImage
);
$this->
assertCount(0,
$errors, 'Should not get any errors for a non-image file.'
);
$errors =
file_validate_image_resolution($this->nonImage, '50x50', '100x100'
);
$this->
assertCount(0,
$errors, 'Do not check the resolution on non files.'
);
// Minimum size.
$errors =
file_validate_image_resolution($this->image
);
$this->
assertCount(0,
$errors, 'No errors for an image when there is no minimum or maximum resolution.'
);
$errors =
file_validate_image_resolution($this->image, 0, '200x1'
);
$this->
assertCount(1,
$errors, 'Got an error for an image that was not wide enough.'
);
$errors =
file_validate_image_resolution($this->image, 0, '1x200'
);
$this->
assertCount(1,
$errors, 'Got an error for an image that was not tall enough.'
);