Skip to content

Commit 9ca38ce

Browse files
committed
Media: Temporarily disable failing tests when Imagick 7 is in use, pending further investigation.
The updated PHP 8.4 and 8.3 containers are running Imagick 7 which is producing some test failures for AVIFs and PNGs with 1-bit transparency. This requires further investigation, possibly accompanied by more comprehensive testing across Imagick versions, so these tests are disabled for now. Additional missing assertions have also been added which ensure an unexpected `WP_Error` instance correctly fails the test and is not passed to an image processing function. Props johnbillion, siliconforks, desrosj, jorbin. See #63932 git-svn-id: https://develop.svn.wordpress.org/trunk@60736 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b6e708d commit 9ca38ce

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

tests/phpunit/tests/image/editorImagick.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,10 @@ static function ( $value ) {
705705
* Test filter `image_max_bit_depth` correctly sets the maximum bit depth of resized images.
706706
*
707707
* @ticket 62285
708+
*
709+
* Temporarily disabled until we can figure out why it fails on the Trixie based PHP container.
710+
* See https://core.trac.wordpress.org/ticket/63932.
711+
* @requires PHP < 8.3
708712
*/
709713
public function test_image_max_bit_depth() {
710714
$file = DIR_TESTDATA . '/images/colors_hdr_p3.avif';
@@ -779,6 +783,14 @@ public function __return_eight() {
779783
*/
780784
public function test_resizes_are_small_for_16bit_images( $file ) {
781785

786+
// Temporarily disabled. See https://core.trac.wordpress.org/ticket/63932.
787+
if ( DIR_TESTDATA . '/images/png-tests/test8.png' === $file ) {
788+
$version = Imagick::getVersion();
789+
if ( $version['versionNumber'] >= 0x700 ) {
790+
$this->markTestSkipped( 'ImageMagick 7 is unable to optimize grayscale images with 1-bit transparency.' );
791+
}
792+
}
793+
782794
$temp_file = DIR_TESTDATA . '/images/test-temp.png';
783795

784796
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
@@ -835,6 +847,14 @@ public static function data_resizes_are_small_for_16bit_images() {
835847
*/
836848
public function test_png_color_type_is_preserved_after_resize( $file_path, $expected_color_type ) {
837849

850+
// Temporarily disabled. See https://core.trac.wordpress.org/ticket/63932.
851+
if ( DIR_TESTDATA . '/images/png-tests/test8.png' === $file_path ) {
852+
$version = Imagick::getVersion();
853+
if ( $version['versionNumber'] >= 0x700 ) {
854+
$this->markTestSkipped( 'ImageMagick 7 is unable to optimize grayscale images with 1-bit transparency.' );
855+
}
856+
}
857+
838858
$temp_file = DIR_TESTDATA . '/images/test-temp.png';
839859

840860
$imagick_image_editor = new WP_Image_Editor_Imagick( $file_path );

tests/phpunit/tests/image/resize.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function wp_image_editors() {
2323
public function test_resize_jpg() {
2424
$image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 );
2525

26+
$this->assertNotWPError( $image );
27+
2628
list( $w, $h, $type ) = getimagesize( $image );
2729

2830
unlink( $image );
@@ -78,6 +80,8 @@ public function test_resize_webp() {
7880

7981
$image = $this->resize_helper( $file, 25, 25 );
8082

83+
$this->assertNotWPError( $image );
84+
8185
list( $w, $h, $type ) = wp_getimagesize( $image );
8286

8387
unlink( $image );
@@ -92,6 +96,10 @@ public function test_resize_webp() {
9296
* Test resizing AVIF image.
9397
*
9498
* @ticket 51228
99+
*
100+
* Temporarily disabled until we can figure out why it fails on the Trixie based PHP container.
101+
* See https://core.trac.wordpress.org/ticket/63932.
102+
* @requires PHP < 8.3
95103
*/
96104
public function test_resize_avif() {
97105
$file = DIR_TESTDATA . '/images/avif-lossy.avif';
@@ -104,6 +112,8 @@ public function test_resize_avif() {
104112

105113
$image = $this->resize_helper( $file, 25, 25 );
106114

115+
$this->assertNotWPError( $image );
116+
107117
list( $w, $h, $type ) = wp_getimagesize( $image );
108118

109119
unlink( $image );
@@ -130,6 +140,8 @@ public function test_resize_heic() {
130140

131141
$image = $this->resize_helper( $file, 25, 25 );
132142

143+
$this->assertNotWPError( $image );
144+
133145
list( $w, $h, $type ) = wp_getimagesize( $image );
134146

135147
unlink( $image );
@@ -151,6 +163,8 @@ public function test_resize_larger() {
151163
public function test_resize_thumb_128x96() {
152164
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );
153165

166+
$this->assertNotWPError( $image );
167+
154168
list( $w, $h, $type ) = getimagesize( $image );
155169

156170
unlink( $image );
@@ -164,6 +178,8 @@ public function test_resize_thumb_128x96() {
164178
public function test_resize_thumb_128x0() {
165179
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 );
166180

181+
$this->assertNotWPError( $image );
182+
167183
list( $w, $h, $type ) = getimagesize( $image );
168184

169185
unlink( $image );
@@ -177,6 +193,8 @@ public function test_resize_thumb_128x0() {
177193
public function test_resize_thumb_0x96() {
178194
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 );
179195

196+
$this->assertNotWPError( $image );
197+
180198
list( $w, $h, $type ) = getimagesize( $image );
181199

182200
unlink( $image );
@@ -190,6 +208,8 @@ public function test_resize_thumb_0x96() {
190208
public function test_resize_thumb_150x150_crop() {
191209
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true );
192210

211+
$this->assertNotWPError( $image );
212+
193213
list( $w, $h, $type ) = getimagesize( $image );
194214

195215
unlink( $image );
@@ -203,6 +223,8 @@ public function test_resize_thumb_150x150_crop() {
203223
public function test_resize_thumb_150x100_crop() {
204224
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true );
205225

226+
$this->assertNotWPError( $image );
227+
206228
list( $w, $h, $type ) = getimagesize( $image );
207229

208230
unlink( $image );
@@ -216,6 +238,8 @@ public function test_resize_thumb_150x100_crop() {
216238
public function test_resize_thumb_50x150_crop() {
217239
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true );
218240

241+
$this->assertNotWPError( $image );
242+
219243
list( $w, $h, $type ) = getimagesize( $image );
220244

221245
unlink( $image );
@@ -240,6 +264,8 @@ public function test_resize_non_existent_image() {
240264

241265
/**
242266
* Function to help out the tests
267+
*
268+
* @return string|WP_Error The path to the resized image file or a WP_Error on failure.
243269
*/
244270
protected function resize_helper( $file, $width, $height, $crop = false ) {
245271
$editor = wp_get_image_editor( $file );

tests/phpunit/tests/media.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5460,6 +5460,9 @@ public function test_quality_with_image_conversion_file_sizes() {
54605460

54615461
// Sub-sizes: for each size, the JPEGs should be smaller than the WebP.
54625462
$sizes_to_compare = array_intersect_key( $jpeg_sizes['sizes'], $webp_sizes['sizes'] );
5463+
5464+
$this->assertNotEmpty( $sizes_to_compare );
5465+
54635466
foreach ( $sizes_to_compare as $size => $size_data ) {
54645467
$this->assertLessThan( $webp_sizes['sizes'][ $size ]['filesize'], $jpeg_sizes['sizes'][ $size ]['filesize'] );
54655468
}
@@ -5469,6 +5472,10 @@ public function test_quality_with_image_conversion_file_sizes() {
54695472
* Test AVIF quality filters.
54705473
*
54715474
* @ticket 61614
5475+
*
5476+
* Temporarily disabled until we can figure out why it fails on the Trixie based PHP container.
5477+
* See https://core.trac.wordpress.org/ticket/63932.
5478+
* @requires PHP < 8.3
54725479
*/
54735480
public function test_quality_with_avif_conversion_file_sizes() {
54745481
$temp_dir = get_temp_dir();
@@ -5503,6 +5510,8 @@ public function test_quality_with_avif_conversion_file_sizes() {
55035510
// Sub-sizes: for each size, the AVIF should be smaller than the JPEG.
55045511
$sizes_to_compare = array_intersect_key( $avif_sizes['sizes'], $smaller_avif_sizes['sizes'] );
55055512

5513+
$this->assertNotEmpty( $sizes_to_compare );
5514+
55065515
foreach ( $sizes_to_compare as $size => $size_data ) {
55075516
$this->assertLessThan( $avif_sizes['sizes'][ $size ]['filesize'], $smaller_avif_sizes['sizes'][ $size ]['filesize'] );
55085517
}

0 commit comments

Comments
 (0)