Skip to content

Commit 75d7ea7

Browse files
committed
Build/Test Tools: Fix tooling and PHPUnit test issues.
This fixes the PHPUnit test suite for the 6.6 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.6 branch. See #63876, #63932. git-svn-id: https://develop.svn.wordpress.org/branches/6.6@60746 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8546959 commit 75d7ea7

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

tests/phpunit/tests/image/editorImagick.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,11 @@ public function test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in
656656
$this->markTestSkipped( 'Rendering PDFs is not supported on this system.' );
657657
}
658658

659+
$version = Imagick::getVersion();
660+
if ( $version['versionNumber'] < 0x675 ) {
661+
$this->markTestSkipped( 'The version of ImageMagick does not support removing alpha channels from PDFs.' );
662+
}
663+
659664
$test_file = DIR_TESTDATA . '/images/test-alpha.pdf';
660665
$attachment_id = $this->factory->attachment->create_upload_object( $test_file );
661666
$this->assertNotEmpty( $attachment_id, 'The attachment was not created before testing.' );

tests/phpunit/tests/image/resize.php

Lines changed: 22 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 );
@@ -125,6 +135,8 @@ public function test_resize_larger() {
125135
public function test_resize_thumb_128x96() {
126136
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );
127137

138+
$this->assertNotWPError( $image );
139+
128140
list( $w, $h, $type ) = getimagesize( $image );
129141

130142
unlink( $image );
@@ -138,6 +150,8 @@ public function test_resize_thumb_128x96() {
138150
public function test_resize_thumb_128x0() {
139151
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 );
140152

153+
$this->assertNotWPError( $image );
154+
141155
list( $w, $h, $type ) = getimagesize( $image );
142156

143157
unlink( $image );
@@ -151,6 +165,8 @@ public function test_resize_thumb_128x0() {
151165
public function test_resize_thumb_0x96() {
152166
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 );
153167

168+
$this->assertNotWPError( $image );
169+
154170
list( $w, $h, $type ) = getimagesize( $image );
155171

156172
unlink( $image );
@@ -164,6 +180,8 @@ public function test_resize_thumb_0x96() {
164180
public function test_resize_thumb_150x150_crop() {
165181
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true );
166182

183+
$this->assertNotWPError( $image );
184+
167185
list( $w, $h, $type ) = getimagesize( $image );
168186

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

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

195215
unlink( $image );
@@ -214,6 +234,8 @@ public function test_resize_non_existent_image() {
214234

215235
/**
216236
* Function to help out the tests
237+
*
238+
* @return string|WP_Error The path to the resized image file or a WP_Error on failure.
217239
*/
218240
protected function resize_helper( $file, $width, $height, $crop = false ) {
219241
$editor = wp_get_image_editor( $file );

tests/phpunit/tests/media.php

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

53115311
// Sub-sizes: for each size, the JPEGs should be smaller than the WebP.
53125312
$sizes_to_compare = array_intersect_key( $jpeg_sizes['sizes'], $webp_sizes['sizes'] );
5313+
5314+
$this->assertNotWPError( $sizes_to_compare );
5315+
53135316
foreach ( $sizes_to_compare as $size => $size_data ) {
53145317
$this->assertLessThan( $webp_sizes['sizes'][ $size ]['filesize'], $jpeg_sizes['sizes'][ $size ]['filesize'] );
53155318
}

tools/local-env/scripts/install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ writeFileSync( 'wp-tests-config.php', testConfig );
3737
// Once the site is available, install WordPress!
3838
wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
3939
.then( () => {
40-
wp_cli( 'db reset --yes' );
40+
wp_cli( 'db reset --yes --defaults' );
4141
const installCommand = process.env.LOCAL_MULTISITE === 'true' ? 'multisite-install' : 'install';
4242
wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
4343
} );

0 commit comments

Comments
 (0)