Skip to content

Commit

Permalink
fix php unit test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sksaju committed Dec 12, 2023
1 parent b07176d commit 58ee0e8
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/unit/test-safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down

0 comments on commit 58ee0e8

Please sign in to comment.