Skip to content

Commit 19a17b2

Browse files
committed
Tests: Improve image editor test coverage.
Remove repeated non-array image-edit inputs. Check native Imagick PDF rendering independently, then assert WordPress PDF support so loader regressions fail instead of being hidden by a skip. Developed in: #15031, #15032 Props huzaifaalmesbah, shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64989 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b9568b8 commit 19a17b2

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎tests/phpunit/tests/image/editorImagick.php‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ public function test_directory_creation() {
656656
* @covers WP_Image_Editor_Imagick::remove_pdf_alpha_channel
657657
*/
658658
public function test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in_preview() {
659-
if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
659+
if ( ! Imagick::queryFormats( 'PDF' ) ) {
660660
$this->markTestSkipped( 'Rendering PDFs is not supported on this system.' );
661661
}
662662

@@ -667,11 +667,21 @@ public function test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in
667667

668668
$test_file = DIR_TESTDATA . '/images/test-alpha.pdf';
669669

670-
$editor = wp_get_image_editor( $test_file );
671-
if ( is_wp_error( $editor ) ) {
672-
$this->markTestSkipped( $editor->get_error_message() );
670+
// Check native PDF rendering without running the WordPress code under test.
671+
$imagick = new Imagick();
672+
try {
673+
$imagick->readImage( $test_file . '[0]' );
674+
} catch ( ImagickException $e ) {
675+
$this->markTestSkipped( 'Imagick cannot render the PDF fixture: ' . $e->getMessage() );
676+
} finally {
677+
$imagick->destroy();
673678
}
674679

680+
$this->assertTrue(
681+
wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ),
682+
'WordPress should support PDFs when native Imagick can render the fixture.'
683+
);
684+
675685
$attachment_id = self::factory()->attachment->create_upload_object( $test_file );
676686
$this->assertNotEmpty( $attachment_id, 'The attachment was not created before testing.' );
677687

‎tests/phpunit/tests/image/imageEditApplyChanges.php‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ public function test_returns_image_unchanged_when_changes_are_not_an_array( $cha
103103
*/
104104
public static function data_changes_that_are_not_an_array() {
105105
return array(
106-
'null' => array( null ),
107-
'false' => array( false ),
108-
'empty string' => array( '' ),
109-
'string' => array( '[{"r":90}]' ),
110-
'object' => array( (object) array( 'r' => 90 ) ),
106+
'null' => array( null ),
107+
'object' => array( (object) array( 'r' => 90 ) ),
111108
);
112109
}
113110

0 commit comments

Comments
 (0)