Changeset 30873
- Timestamp:
- 12/15/2014 09:24:21 PM (10 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/mock-image-editor.php
r25380 r30873 8 8 public static $test_return = true; 9 9 public static $save_return = array(); 10 11 // Allow testing of jpeg_quality filter. 12 public function set_mime_type( $mime_type = null ) { 13 $this->mime_type = $mime_type; 14 } 10 15 11 16 public function load() { -
trunk/tests/phpunit/tests/image/editor.php
r29834 r30873 52 52 // Get an editor 53 53 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 54 $editor->set_mime_type( "image/jpeg" ); // Ensure mime-specific filters act properly. 54 55 55 56 // Check default value 56 57 $this->assertEquals( 90, $editor->get_quality() ); 57 58 58 // Ensure set_quality works 59 // Ensure the quality filters do not have precedence if created after editor instantiation. 60 $func_100_percent = create_function( '', "return 100;" ); 61 add_filter( 'wp_editor_set_quality', $func_100_percent ); 62 $this->assertEquals( 90, $editor->get_quality() ); 63 64 $func_95_percent = create_function( '', "return 95;" ); 65 add_filter( 'jpeg_quality', $func_95_percent ); 66 $this->assertEquals( 90, $editor->get_quality() ); 67 68 // Ensure set_quality() works and overrides the filters 59 69 $this->assertTrue( $editor->set_quality( 75 ) ); 60 70 $this->assertEquals( 75, $editor->get_quality() ); 61 71 62 // Ensure the quality filter works 63 $func = create_function( '', "return 100;"); 64 add_filter( 'wp_editor_set_quality', $func ); 65 $this->assertTrue( $editor->set_quality( 70 ) ); 66 $this->assertEquals( 70, $editor->get_quality() ); 72 // Get a new editor to clear default quality state 73 unset( $editor ); 74 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 75 $editor->set_mime_type( "image/jpeg" ); // Ensure mime-specific filters act properly. 76 77 // Ensure jpeg_quality filter applies if it exists before editor instantiation. 78 $this->assertEquals( 95, $editor->get_quality() ); 79 80 // Get a new editor to clear jpeg_quality state 81 remove_filter( 'jpeg_quality', $func_95_percent ); 82 unset( $editor ); 83 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 84 85 // Ensure wp_editor_set_quality filter applies if it exists before editor instantiation. 86 $this->assertEquals( 100, $editor->get_quality() ); 67 87 68 88 // Clean up 69 remove_filter( 'wp_editor_set_quality', $func );89 remove_filter( 'wp_editor_set_quality', $func_100_percent ); 70 90 } 71 91
Note: See TracChangeset
for help on using the changeset viewer.