Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/phpunit/tests/image/editorImagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,11 @@ public function test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in
$this->markTestSkipped( 'Rendering PDFs is not supported on this system.' );
}

$version = Imagick::getVersion();
if ( $version['versionNumber'] < 0x675 ) {
$this->markTestSkipped( 'The version of ImageMagick does not support removing alpha channels from PDFs.' );
}

$test_file = DIR_TESTDATA . '/images/test-alpha.pdf';
$attachment_id = $this->factory->attachment->create_upload_object( $test_file );
$this->assertNotEmpty( $attachment_id, 'The attachment was not created before testing.' );
Expand Down
22 changes: 22 additions & 0 deletions tests/phpunit/tests/image/resize.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function wp_image_editors() {
public function test_resize_jpg() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 );

$this->assertNotWPError( $image );

list( $w, $h, $type ) = getimagesize( $image );

unlink( $image );
Expand Down Expand Up @@ -78,6 +80,8 @@ public function test_resize_webp() {

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

$this->assertNotWPError( $image );

list( $w, $h, $type ) = wp_getimagesize( $image );

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

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

$this->assertNotWPError( $image );

list( $w, $h, $type ) = wp_getimagesize( $image );

unlink( $image );
Expand All @@ -125,6 +135,8 @@ public function test_resize_larger() {
public function test_resize_thumb_128x96() {
$image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );

$this->assertNotWPError( $image );

list( $w, $h, $type ) = getimagesize( $image );

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

$this->assertNotWPError( $image );

list( $w, $h, $type ) = getimagesize( $image );

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

$this->assertNotWPError( $image );

list( $w, $h, $type ) = getimagesize( $image );

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

$this->assertNotWPError( $image );

list( $w, $h, $type ) = getimagesize( $image );

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

$this->assertNotWPError( $image );

list( $w, $h, $type ) = getimagesize( $image );

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

/**
* Function to help out the tests
*
* @return string|WP_Error The path to the resized image file or a WP_Error on failure.
*/
protected function resize_helper( $file, $width, $height, $crop = false ) {
$editor = wp_get_image_editor( $file );
Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit/tests/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -5310,6 +5310,9 @@ public function test_quality_with_image_conversion_file_sizes() {

// Sub-sizes: for each size, the JPEGs should be smaller than the WebP.
$sizes_to_compare = array_intersect_key( $jpeg_sizes['sizes'], $webp_sizes['sizes'] );

$this->assertNotWPError( $sizes_to_compare );

foreach ( $sizes_to_compare as $size => $size_data ) {
$this->assertLessThan( $webp_sizes['sizes'][ $size ]['filesize'], $jpeg_sizes['sizes'][ $size ]['filesize'] );
}
Expand Down
2 changes: 1 addition & 1 deletion tools/local-env/scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ writeFileSync( 'wp-tests-config.php', testConfig );
// Once the site is available, install WordPress!
wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
.then( () => {
wp_cli( 'db reset --yes' );
wp_cli( 'db reset --yes --defaults' );
const installCommand = process.env.LOCAL_MULTISITE === 'true' ? 'multisite-install' : 'install';
wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password --admin_email=test@test.com --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
} );
Expand Down
Loading