In multi_resize() image editor methods, assert that null can only be passed for one of the arguments, not both. Add a lot more unit test assertions to ensure this.

Props pbearne, DH-Shredder.
Fixes #26823.



git-svn-id: https://develop.svn.wordpress.org/trunk@27794 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-03-27 20:39:08 +00:00
parent 75ee98cb25
commit 7b7e5305c7
6 changed files with 798 additions and 82 deletions

View File

@@ -39,12 +39,35 @@ abstract class WP_Image_UnitTestCase extends WP_UnitTestCase {
* @param int $alpha
*/
protected function assertImageAlphaAtPoint( $image_path, $point, $alpha ) {
$im = imagecreatefrompng( $image_path );
$rgb = imagecolorat($im, $point[0], $point[1]);
$rgb = imagecolorat( $im, $point[0], $point[1] );
$colors = imagecolorsforindex($im, $rgb);
$colors = imagecolorsforindex( $im, $rgb );
$this->assertEquals( $alpha, $colors['alpha'] );
}
/**
* Helper assertion to check actual image dimensions on disk
*
* @param string $filename Image filename.
* @param int $width Width to verify.
* @param int $height Height to verify.
*/
protected function assertImageDimensions( $filename, $width, $height ) {
$detected_width = 0;
$detected_height = 0;
$image_size = @getimagesize( $filename );
if ( isset( $image_size[0] ) ) {
$detected_width = $image_size[0];
}
if ( isset( $image_size[1] ) ) {
$detected_height = $image_size[1];
}
$this->assertEquals( $width, $detected_width );
$this->assertEquals( $height, $detected_height );
}
}