mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user