Changeset 54097 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 09/07/2022 09:43:28 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r54086 r54097 3627 3627 */ 3628 3628 public function test_wp_default_image_output_mapping() { 3629 $mapping = wp_default_image_output_mapping( array() );3629 $mapping = wp_default_image_output_mapping( array(), 'test.jpg', 'image/jpeg', '' ); 3630 3630 $this->assertSame( array( 'image/jpeg' => 'image/webp' ), $mapping ); 3631 3631 } … … 3638 3638 public function test_wp_default_image_output_mapping_existing() { 3639 3639 $mapping = array( 'mime/png' => 'mime/webp' ); 3640 $mapping = wp_default_image_output_mapping( $mapping );3640 $mapping = wp_default_image_output_mapping( $mapping, 'test.jpg', 'image/jpeg', '' ); 3641 3641 $this->assertSame( 3642 3642 array( … … 3673 3673 } 3674 3674 } 3675 3676 /** 3677 * @ticket 56526 3678 * @dataProvider data_wp_default_image_output_mapping_size_filter 3679 */ 3680 public function test_wp_default_image_output_mapping_size_filter( $size_name, $filter_callback, $expects_webp ) { 3681 remove_all_filters( 'wp_image_sizes_with_additional_mime_type_support' ); 3682 if ( $filter_callback ) { 3683 add_filter( 'wp_image_sizes_with_additional_mime_type_support', $filter_callback ); 3684 } 3685 3686 $mapping = wp_default_image_output_mapping( array(), 'test.jpg', 'image/jpeg', $size_name ); 3687 if ( $expects_webp ) { 3688 $this->assertSame( array( 'image/jpeg' => 'image/webp' ), $mapping ); 3689 } else { 3690 $this->assertSame( array(), $mapping ); 3691 } 3692 } 3693 3694 public function data_wp_default_image_output_mapping_size_filter() { 3695 return array( 3696 'default size thumbnail' => array( 3697 'thumbnail', 3698 null, 3699 true, 3700 ), 3701 'default size medium' => array( 3702 'medium', 3703 null, 3704 true, 3705 ), 3706 'default size medium_large' => array( 3707 'medium_large', 3708 null, 3709 true, 3710 ), 3711 'default size large' => array( 3712 'large', 3713 null, 3714 true, 3715 ), 3716 'default size unset' => array( 3717 'medium', 3718 function( $enabled_sizes ) { 3719 unset( $enabled_sizes['medium'] ); 3720 return $enabled_sizes; 3721 }, 3722 false, 3723 ), 3724 'default size set to false' => array( 3725 'medium', 3726 function( $enabled_sizes ) { 3727 $enabled_sizes['medium'] = false; 3728 return $enabled_sizes; 3729 }, 3730 false, 3731 ), 3732 'custom size' => array( 3733 'custom', 3734 null, 3735 false, 3736 ), 3737 'custom size opted in' => array( 3738 'custom', 3739 function( $enabled_sizes ) { 3740 $enabled_sizes['custom'] = true; 3741 return $enabled_sizes; 3742 }, 3743 true, 3744 ), 3745 ); 3746 } 3675 3747 } 3676 3748
Note: See TracChangeset
for help on using the changeset viewer.