Fix setting default quality in WP_Image_Editor.

props markoheijnen.
fixes #29856 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@29834 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2014-10-04 13:11:38 +00:00
parent 07a38ff81a
commit 1a7c4efa13
7 changed files with 32 additions and 10 deletions
+5 -2
View File
@@ -52,6 +52,9 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase {
// Get an editor
$editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
// Check default value
$this->assertEquals( 90, $editor->get_quality() );
// Ensure set_quality works
$this->assertTrue( $editor->set_quality( 75 ) );
$this->assertEquals( 75, $editor->get_quality() );
@@ -59,8 +62,8 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase {
// Ensure the quality filter works
$func = create_function( '', "return 100;");
add_filter( 'wp_editor_set_quality', $func );
$this->assertTrue( $editor->set_quality( 75 ) );
$this->assertEquals( 75, $editor->get_quality() );
$this->assertTrue( $editor->set_quality( 70 ) );
$this->assertEquals( 70, $editor->get_quality() );
// Clean up
remove_filter( 'wp_editor_set_quality', $func );
+6
View File
@@ -463,6 +463,9 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
$file = DIR_TESTDATA . '/images/transparent.png';
$editor = wp_get_image_editor( $file );
$this->assertNotInstanceOf( 'WP_Error', $editor );
$editor->load();
$editor->resize( 5, 5 );
$save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
@@ -483,6 +486,9 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
$file = DIR_TESTDATA . '/images/transparent.png';
$editor = wp_get_image_editor( $file );
$this->assertNotInstanceOf( 'WP_Error', $editor );
$editor->load();
$save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
@@ -463,6 +463,9 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$file = DIR_TESTDATA . '/images/transparent.png';
$editor = wp_get_image_editor( $file );
$this->assertNotInstanceOf( 'WP_Error', $editor );
$editor->load();
$editor->resize( 5, 5 );
$save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
@@ -483,6 +486,9 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$file = DIR_TESTDATA . '/images/transparent.png';
$editor = wp_get_image_editor( $file );
$this->assertNotInstanceOf( 'WP_Error', $editor );
$editor->load();
$save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
+2
View File
@@ -224,6 +224,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
// Save the image as each file extension, check the mime type
$img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
$this->assertNotInstanceOf( 'WP_Error', $img );
$temp = get_temp_dir();
foreach ( $mime_types as $ext => $mime_type ) {
$file = wp_unique_filename( $temp, uniqid() . ".$ext" );