@@ -926,29 +926,34 @@ public function it_should_create_mime_types_for_allowed_sizes_only_via_global_va
926926 * @test
927927 */
928928 public function it_should_set_quality_with_image_conversion () {
929- $ editor = wp_get_image_editor ( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dice.png ' , array ( 'mime_type ' => 'image/png ' ) );
930-
931- // Quality setting for the source image. For PNG the fallback default of 82 is used.
932- $ this ->assertSame ( 82 , $ editor ->get_quality (), 'Default quality setting for PNG is 82. ' );
933-
934- // Temporary file.
929+ // Temporary file path.
935930 $ file = wp_tempnam ();
936931
932+ $ editor = wp_get_image_editor ( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dice.png ' , array ( 'mime_type ' => 'image/png ' ) );
933+ $ png_quality = $ editor ->get_quality ();
934+
937935 // A PNG image will be converted to WebP whose quality should be 82 universally.
938936 $ editor ->save ( $ file , 'image/webp ' );
939- $ this ->assertSame ( 82 , $ editor ->get_quality (), 'Output image format is WebP. Quality setting for it should be 82 universally. ' );
940-
941- $ editor = wp_get_image_editor ( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leafs.jpg ' );
937+ $ png_to_webp_quality = $ editor ->get_quality ();
942938
943- // Quality setting for the source image. For JPG the fallback default of 82 is used.
944- $ this -> assertSame ( 82 , $ editor ->get_quality (), ' Default quality setting for JPG is 82. ' );
939+ $ editor = wp_get_image_editor ( TESTS_PLUGIN_DIR . ' /tests/testdata/modules/images/leafs.jpg ' );
940+ $ jpg_quality = $ editor ->get_quality ();
945941
946942 // A JPG image will be converted to WebP whose quality should be 82 universally.
947943 $ editor ->save ( $ file , 'image/webp ' );
948- $ this -> assertSame ( 82 , $ editor ->get_quality (), ' Output image format is WebP. Quality setting for it should be 82 universally. ' );
944+ $ jpg_to_webp_quality = $ editor ->get_quality ();
949945
950- // Delete the temporary file.
946+ // Delete the temporary file before assertions .
951947 unlink ( $ file );
948+
949+ // Quality setting for the source image. For PNG the fallback default of 82 is used.
950+ $ this ->assertSame ( 82 , $ png_quality , 'Default quality setting for PNG is 82. ' );
951+
952+ // Quality setting for the source image. For JPG the fallback default of 82 is used.
953+ $ this ->assertSame ( 82 , $ jpg_quality , 'Default quality setting for JPG is 82. ' );
954+
955+ $ this ->assertSame ( 82 , $ png_to_webp_quality , 'Output image format is WebP. Quality setting for it should be 82 universally. ' );
956+ $ this ->assertSame ( 82 , $ jpg_to_webp_quality , 'Output image format is WebP. Quality setting for it should be 82 universally. ' );
952957 }
953958
954959 /**
0 commit comments