Changeset 35569 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 11/07/2015 09:35:34 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r35561 r35569 755 755 $image_url = wp_get_attachment_image_url( self::$large_id, $size ); 756 756 $size_array = $this->_get_image_size_array_from_name( $size ); 757 $this->assertSame( $expected, wp_calculate_image_srcset( $ image_url, $size_array, $image_meta ) );757 $this->assertSame( $expected, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); 758 758 } 759 759 } … … 787 787 $size_array = $this->_get_image_size_array_from_name( $size ); 788 788 $image_url = wp_get_attachment_image_url( $id, $size ); 789 $this->assertSame( $expected, wp_calculate_image_srcset( $ image_url, $size_array, $image_meta ) );789 $this->assertSame( $expected, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); 790 790 } 791 791 … … 822 822 823 823 // Calculate a srcset array. 824 $sizes = explode( ', ', wp_calculate_image_srcset( $ image_url, $size_array, $image_meta ) );824 $sizes = explode( ', ', wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); 825 825 826 826 // Test to confirm all sources in the array include the same edit hash. … … 834 834 */ 835 835 function test_wp_calculate_image_srcset_false() { 836 $sizes = wp_calculate_image_srcset( 'file.png', array( 400, 300 ), array() );836 $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() ); 837 837 838 838 // For canola.jpg we should return … … 850 850 $size_array = array(0, 0); 851 851 852 $srcset = wp_calculate_image_srcset( $ image_url, $size_array, $image_meta );852 $srcset = wp_calculate_image_srcset( $size_array, $image_url, $image_meta ); 853 853 854 854 // The srcset should be false. … … 915 915 // Test sizes against the default WP sizes. 916 916 $intermediates = array('thumbnail', 'medium', 'medium_large', 'large'); 917 918 foreach( $intermediates as $int_size ) { 919 $image = wp_get_attachment_image_src( self::$large_id, $int_size ); 920 921 $expected = '(max-width: ' . $image[1] . 'px) 100vw, ' . $image[1] . 'px'; 922 $sizes = wp_get_attachment_image_sizes( self::$large_id, $int_size ); 923 924 $this->assertSame( $expected, $sizes ); 925 } 926 } 927 928 /** 929 * @ticket 33641 930 */ 931 function test_wp_calculate_image_sizes() { 932 // Test sizes against the default WP sizes. 933 $intermediates = array('thumbnail', 'medium', 'medium_large', 'large'); 917 934 $image_meta = wp_get_attachment_metadata( self::$large_id ); 918 935 919 936 foreach( $intermediates as $int_size ) { 920 937 $size_array = $this->_get_image_size_array_from_name( $int_size ); 938 $image_src = $image_meta['sizes'][$int_size]['file']; 921 939 list( $width, $height ) = $size_array; 922 940 923 941 $expected = '(max-width: ' . $width . 'px) 100vw, ' . $width . 'px'; 924 $sizes = wp_ get_attachment_image_sizes( $size_array, $image_meta );942 $sizes = wp_calculate_image_sizes( $size_array, $image_src, $image_meta ); 925 943 926 944 $this->assertSame( $expected, $sizes ); … … 936 954 937 955 $srcset = sprintf( 'srcset="%s"', wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta ) ); 938 $sizes = sprintf( 'sizes="%s"', wp_get_attachment_image_sizes( $size_array, $image_meta, self::$large_id) );956 $sizes = sprintf( 'sizes="%s"', wp_get_attachment_image_sizes( self::$large_id, $size_array, $image_meta ) ); 939 957 940 958 // Function used to build HTML for the editor. … … 1020 1038 1021 1039 // Full size GIFs should not return a srcset. 1022 $this->assertFalse( wp_calculate_image_srcset( $ full_src, $size_array, $image_meta ) );1040 $this->assertFalse( wp_calculate_image_srcset( $size_array, $full_src, $image_meta ) ); 1023 1041 // Intermediate sized GIFs should not include the full size in the srcset. 1024 $this->assertFalse( strpos( wp_calculate_image_srcset( $ large_src, $size_array, $image_meta ), $full_src ) );1042 $this->assertFalse( strpos( wp_calculate_image_srcset( $size_array, $large_src, $image_meta ), $full_src ) ); 1025 1043 } 1026 1044 }
Note: See TracChangeset
for help on using the changeset viewer.