diff --git a/plugins/dominant-color-images/tests/test-dominant-color-image-editor-imagick.php b/plugins/dominant-color-images/tests/test-dominant-color-image-editor-imagick.php index 5e30e89d51..7e99eb728d 100644 --- a/plugins/dominant-color-images/tests/test-dominant-color-image-editor-imagick.php +++ b/plugins/dominant-color-images/tests/test-dominant-color-image-editor-imagick.php @@ -26,17 +26,26 @@ public function set_up(): void { $this->markTestSkipped( 'The Imagick PHP extension is not loaded.' ); } - add_filter( - 'wp_image_editors', - static function ( array $editors ): array { - return array_filter( - $editors, - static function ( $editor ): bool { - return WP_Image_Editor_Imagick::class === $editor; - } - ); - } - ); + $required_formats = array( 'JPEG', 'PNG', 'GIF', 'WEBP' ); + try { + $supported_formats = Imagick::queryFormats(); + } catch ( Exception $exception ) { + $this->markTestSkipped( sprintf( 'Unable to query Imagick formats: %s', $exception->getMessage() ) ); + } + $missing_formats = array_diff( $required_formats, $supported_formats ); + if ( 0 === count( $missing_formats ) ) { + add_filter( + 'wp_image_editors', + static function ( array $editors ): array { + return array_filter( + $editors, + static function ( $editor ): bool { + return WP_Image_Editor_Imagick::class === $editor; + } + ); + } + ); + } } /**