Skip to content

Commit 4e244a6

Browse files
committed
Build/Test Tools: Fix tooling and PHPUnit test issues.
This fixes the PHPUnit test suite for the 6.8 branch by: - Fixing issues with the `env:install` script when using newer PHP images. - Temporarily disables failing tests with ImageMagick 7 is in use. Backports [60735] and [60736] to the 6.8 branch. See #63876, #63932. git-svn-id: https://develop.svn.wordpress.org/branches/6.8@60744 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 646fd23 commit 4e244a6

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

tests/phpunit/tests/image/editorImagick.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ static function ( $value ) {
701701
* Test filter `image_max_bit_depth` correctly sets the maximum bit depth of resized images.
702702
*
703703
* @ticket 62285
704+
*
705+
* Temporarily disabled until we can figure out why it fails on the Trixie based PHP container.
706+
* See https://core.trac.wordpress.org/ticket/63932.
707+
* @requires PHP < 8.3
704708
*/
705709
public function test_image_max_bit_depth() {
706710
$file = DIR_TESTDATA . '/images/colors_hdr_p3.avif';
@@ -773,6 +777,14 @@ public function __return_eight() {
773777
*/
774778
public function test_resizes_are_small_for_16bit_images( $file ) {
775779

780+
// Temporarily disabled. See https://core.trac.wordpress.org/ticket/63932.
781+
if ( DIR_TESTDATA . '/images/png-tests/test8.png' === $file ) {
782+
$version = Imagick::getVersion();
783+
if ( $version['versionNumber'] >= 0x700 ) {
784+
$this->markTestSkipped( 'ImageMagick 7 is unable to optimize grayscale images with 1-bit transparency.' );
785+
}
786+
}
787+
776788
$temp_file = DIR_TESTDATA . '/images/test-temp.png';
777789

778790
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );

tests/phpunit/tests/image/resize.php

Lines changed: 24 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 );
@@ -216,6 +236,8 @@ public function test_resize_thumb_150x100_crop() {
216236
public function test_resize_thumb_50x150_crop() {
217237
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true );
218238

239+
$this->assertNotWPError( $image );
240+
219241
list( $w, $h, $type ) = getimagesize( $image );
220242

221243
unlink( $image );
@@ -240,6 +262,8 @@ public function test_resize_non_existent_image() {
240262

241263
/**
242264
* Function to help out the tests
265+
*
266+
* @return string|WP_Error The path to the resized image file or a WP_Error on failure.
243267
*/
244268
protected function resize_helper( $file, $width, $height, $crop = false ) {
245269
$editor = wp_get_image_editor( $file );

tests/phpunit/tests/media.php

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

54365436
// Sub-sizes: for each size, the JPEGs should be smaller than the WebP.
54375437
$sizes_to_compare = array_intersect_key( $jpeg_sizes['sizes'], $webp_sizes['sizes'] );
5438+
5439+
$this->assertNotWPError( $sizes_to_compare );
5440+
54385441
foreach ( $sizes_to_compare as $size => $size_data ) {
54395442
$this->assertLessThan( $webp_sizes['sizes'][ $size ]['filesize'], $jpeg_sizes['sizes'][ $size ]['filesize'] );
54405443
}
@@ -5478,6 +5481,8 @@ public function test_quality_with_avif_conversion_file_sizes() {
54785481
// Sub-sizes: for each size, the AVIF should be smaller than the JPEG.
54795482
$sizes_to_compare = array_intersect_key( $avif_sizes['sizes'], $smaller_avif_sizes['sizes'] );
54805483

5484+
$this->assertNotWPError( $sizes_to_compare );
5485+
54815486
foreach ( $sizes_to_compare as $size => $size_data ) {
54825487
$this->assertLessThan( $avif_sizes['sizes'][ $size ]['filesize'], $smaller_avif_sizes['sizes'][ $size ]['filesize'] );
54835488
}

tools/local-env/scripts/install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ wait_on( {
5050
process.exit( 1 );
5151
} )
5252
.then( () => {
53-
wp_cli( 'db reset --yes' );
53+
wp_cli( 'db reset --yes --defaults' );
5454
const installCommand = process.env.LOCAL_MULTISITE === 'true' ? 'multisite-install' : 'install';
5555
wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
5656
} )

0 commit comments

Comments
 (0)