Media: Improve and fix rotate/flip image tests
Fix off-by-one error in pixel color checks for rotate and flip image tests. Change to using PNG with single pixel to ensure that errors are caught in the future, rather than lost in JPEG noise. Props Fuegas, mikeschroder. Fixes #46073. git-svn-id: https://develop.svn.wordpress.org/trunk@45067 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
752f99c5df
commit
2a7aedc9e0
BIN
tests/phpunit/data/images/one-blue-pixel-100x100.png
Normal file
BIN
tests/phpunit/data/images/one-blue-pixel-100x100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 320 B |
@ -421,7 +421,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
||||
* Test rotating an image 180 deg
|
||||
*/
|
||||
public function test_rotate() {
|
||||
$file = DIR_TESTDATA . '/images/gradient-square.jpg';
|
||||
$file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
|
||||
|
||||
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
|
||||
$imagick_image_editor->load();
|
||||
@ -429,7 +429,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
||||
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
|
||||
$property->setAccessible( true );
|
||||
|
||||
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
|
||||
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
|
||||
|
||||
$imagick_image_editor->rotate( 180 );
|
||||
|
||||
@ -440,7 +440,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
||||
* Test flipping an image
|
||||
*/
|
||||
public function test_flip() {
|
||||
$file = DIR_TESTDATA . '/images/gradient-square.jpg';
|
||||
$file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
|
||||
|
||||
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
|
||||
$imagick_image_editor->load();
|
||||
@ -448,7 +448,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
||||
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
|
||||
$property->setAccessible( true );
|
||||
|
||||
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
|
||||
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
|
||||
|
||||
$imagick_image_editor->flip( true, false );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user