Changeset 54086 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 09/06/2022 09:13:17 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r54085 r54086 34 34 $GLOBALS['_wp_additional_image_sizes'] = array(); 35 35 36 $filename = DIR_TESTDATA . '/images/' . self::$large_filename; 36 $filename = DIR_TESTDATA . '/images/' . self::$large_filename; 37 add_filter( 'image_editor_output_format', '__return_empty_array' ); 37 38 self::$large_id = $factory->attachment->create_upload_object( $filename ); 38 39 … … 69 70 public static function wpTearDownAfterClass() { 70 71 $GLOBALS['_wp_additional_image_sizes'] = self::$_sizes; 72 remove_filter( 'image_editor_output_format', '__return_empty_array' ); 71 73 } 72 74 … … 3618 3620 remove_filter( 'wp_omit_loading_attr_threshold', '__return_null', 100 ); 3619 3621 } 3622 3623 /** 3624 * Test the wp_default_image_output_mapping function. 3625 * 3626 * @ticket 55443 3627 */ 3628 public function test_wp_default_image_output_mapping() { 3629 $mapping = wp_default_image_output_mapping( array() ); 3630 $this->assertSame( array( 'image/jpeg' => 'image/webp' ), $mapping ); 3631 } 3632 3633 /** 3634 * Test that wp_default_image_output_mapping doesn't overwrite existing mappings. 3635 * 3636 * @ticket 55443 3637 */ 3638 public function test_wp_default_image_output_mapping_existing() { 3639 $mapping = array( 'mime/png' => 'mime/webp' ); 3640 $mapping = wp_default_image_output_mapping( $mapping ); 3641 $this->assertSame( 3642 array( 3643 'mime/png' => 'mime/webp', 3644 'image/jpeg' => 'image/webp', 3645 ), 3646 $mapping 3647 ); 3648 } 3649 3650 /** 3651 * Test that the image editor default output for JPEGs is WebP. 3652 * 3653 * @ticket 55443 3654 */ 3655 public function test_wp_image_editor_default_output_maps_to_webp() { 3656 remove_filter( 'image_editor_output_format', '__return_empty_array' ); 3657 3658 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 3659 $this->assertNotWPError( $editor ); 3660 3661 $resized = $editor->resize( 100, 100, false ); 3662 $this->assertNotWPError( $resized ); 3663 3664 $saved = $editor->save(); 3665 $this->assertNotWPError( $saved ); 3666 3667 if ( $editor->supports_mime_type( 'image/webp' ) ) { 3668 $this->assertSame( 'image/webp', $saved['mime-type'] ); 3669 $this->assertSame( 'canola-100x75-jpg.webp', $saved['file'] ); 3670 } else { 3671 $this->assertSame( 'image/jpeg', $saved['mime-type'] ); 3672 $this->assertSame( 'canola-100x75.jpg', $saved['file'] ); 3673 } 3674 } 3620 3675 } 3621 3676
Note: See TracChangeset
for help on using the changeset viewer.