From 58ee0e8249eebf551f2c171e0c00c05c50093d03 Mon Sep 17 00:00:00 2001 From: sksaju Date: Tue, 12 Dec 2023 20:45:53 +0600 Subject: [PATCH] fix php unit test issue --- tests/unit/test-safe-svg.php | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/unit/test-safe-svg.php b/tests/unit/test-safe-svg.php index 93bfe203..ab56eae2 100644 --- a/tests/unit/test-safe-svg.php +++ b/tests/unit/test-safe-svg.php @@ -208,6 +208,64 @@ public function test_one_pixel_fix() { ) ); + \WP_Mock::userFunction( + 'wp_get_attachment_metadata', + array( + 'args' => 1, + 'return_in_order' => array( + array( + 'width' => 600, + 'height' => 600, + 'file' => __DIR__ . '/files/svgCleanOne.svg', + 'sizes' => array( + 'thumbnail' => array( + 'width' => 150, + 'height' => 150, + 'crop' => 1, + 'file' => 'svgCleanOne.svg', + 'mime-type' => 'image/svg+xml', + ), + 'medium' => array( + 'width' => 300, + 'height' => 300, + 'crop' => 0, // Set to 0 if you don't want to crop + 'file' => 'svgCleanOne.svg', + 'mime-type' => 'image/svg+xml', + ), + 'medium_large' => array( + 'width' => 768, + 'height' => 0, + 'crop' => 0, + 'file' => 'svgCleanOne.svg', + 'mime-type' => 'image/svg+xml', + ), + 'large' => array( + 'width' => 1024, + 'height' => 1024, + 'crop' => 0, + 'file' => 'svgCleanOne.svg', + 'mime-type' => 'image/svg+xml', + ), + '1536x1536' => array( + 'width' => 1536, + 'height' => 1536, + 'crop' => 0, + 'file' => 'svgCleanOne.svg', + 'mime-type' => 'image/svg+xml', + ), + '2048x2048' => array( + 'width' => 2048, + 'height' => 2048, + 'crop' => 0, + 'file' => 'svgCleanOne.svg', + 'mime-type' => 'image/svg+xml', + ), + ), + ), + ), + ) + ); + // Test SVG Dimensions $image_sizes = $this->instance->one_pixel_fix( array(), 1, 'thumbnail', false ); if ( ! empty( $image_sizes ) ) {