Changeset 42343 for trunk/tests/phpunit/tests/image/intermediateSize.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/intermediateSize.php
r41261 r42343 18 18 public function _make_attachment( $file, $parent_post_id = 0 ) { 19 19 $contents = file_get_contents( $file ); 20 $upload = wp_upload_bits( basename( $file ), null, $contents );20 $upload = wp_upload_bits( basename( $file ), null, $contents ); 21 21 22 22 return parent::_make_attachment( $upload, $parent_post_id ); … … 30 30 31 31 function test_make_intermediate_size_width() { 32 if ( ! function_exists( 'imagejpeg' ) )32 if ( ! function_exists( 'imagejpeg' ) ) { 33 33 $this->fail( 'jpeg support unavailable' ); 34 } 34 35 35 36 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false ); … … 39 40 40 41 function test_make_intermediate_size_height() { 41 if ( ! function_exists( 'imagejpeg' ) )42 if ( ! function_exists( 'imagejpeg' ) ) { 42 43 $this->fail( 'jpeg support unavailable' ); 44 } 43 45 44 46 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false ); … … 48 50 49 51 function test_make_intermediate_size_successful() { 50 if ( ! function_exists( 'imagejpeg' ) )52 if ( ! function_exists( 'imagejpeg' ) ) { 51 53 $this->fail( 'jpeg support unavailable' ); 54 } 52 55 53 56 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true ); … … 64 67 65 68 /** 66 * @ticket 1762667 */69 * @ticket 17626 70 */ 68 71 function test_get_intermediate_sizes_by_name() { 69 72 add_image_size( 'test-size', 330, 220, true ); 70 73 71 74 $file = DIR_TESTDATA . '/images/waffles.jpg'; 72 $id = $this->_make_attachment( $file, 0 );75 $id = $this->_make_attachment( $file, 0 ); 73 76 74 77 // look for a size by name … … 84 87 85 88 /** 86 * @ticket 1762687 */89 * @ticket 17626 90 */ 88 91 function test_get_intermediate_sizes_by_array_exact() { 89 92 // Only one dimention match shouldn't return false positive (see: 17626) … … 93 96 94 97 $file = DIR_TESTDATA . '/images/waffles.jpg'; 95 $id = $this->_make_attachment( $file, 0 );98 $id = $this->_make_attachment( $file, 0 ); 96 99 97 100 // look for a size by array that exists … … 105 108 106 109 /** 107 * @ticket 17626108 */110 * @ticket 17626 111 */ 109 112 function test_get_intermediate_sizes_by_array_nearest() { 110 113 // If an exact size is not found, it should be returned … … 115 118 116 119 $file = DIR_TESTDATA . '/images/waffles.jpg'; 117 $id = $this->_make_attachment( $file, 0 );120 $id = $this->_make_attachment( $file, 0 ); 118 121 119 122 // look for a size by array that doesn't exist … … 127 130 128 131 /** 129 * @ticket 17626130 */132 * @ticket 17626 133 */ 131 134 function test_get_intermediate_sizes_by_array_nearest_false() { 132 135 // If an exact size is not found, it should be returned … … 136 139 137 140 $file = DIR_TESTDATA . '/images/waffles.jpg'; 138 $id = $this->_make_attachment( $file, 0 );141 $id = $this->_make_attachment( $file, 0 ); 139 142 140 143 // look for a size by array that doesn't exist … … 148 151 149 152 /** 150 * @ticket 17626151 */153 * @ticket 17626 154 */ 152 155 function test_get_intermediate_sizes_by_array_zero_height() { 153 156 // Generate random width … … 159 162 160 163 $file = DIR_TESTDATA . '/images/waffles.jpg'; 161 $id = $this->_make_attachment( $file, 0 );164 $id = $this->_make_attachment( $file, 0 ); 162 165 163 166 $original = wp_get_attachment_metadata( $id ); 164 $image_w = $random_w;165 $image_h = round( ( $image_w / $original['width'] ) * $original['height'] );167 $image_w = $random_w; 168 $image_h = round( ( $image_w / $original['width'] ) * $original['height'] ); 166 169 167 170 // look for a size by array that exists … … 187 190 188 191 $file = DIR_TESTDATA . '/images/waffles.jpg'; 189 $id = $this->_make_attachment( $file, 0 );192 $id = $this->_make_attachment( $file, 0 ); 190 193 191 194 $original = wp_get_attachment_metadata( $id ); 192 $image_h = $height;193 $image_w = round( ( $image_h / $original['height'] ) * $original['width'] );195 $image_h = $height; 196 $image_w = round( ( $image_h / $original['height'] ) * $original['width'] ); 194 197 195 198 // look for a size by array that exists … … 213 216 214 217 $file = DIR_TESTDATA . '/images/waffles.jpg'; 215 $id = $this->_make_attachment( $file, 0 );218 $id = $this->_make_attachment( $file, 0 ); 216 219 217 220 $original = wp_get_attachment_metadata( $id ); 218 $image_h = $height;219 $image_w = round( ( $image_h / $original['height'] ) * $original['width'] );221 $image_h = $height; 222 $image_w = round( ( $image_h / $original['height'] ) * $original['width'] ); 220 223 221 224 // look for a size by array that exists … … 234 237 235 238 $file = DIR_TESTDATA . '/images/waffles.jpg'; 236 $id = $this->_make_attachment( $file, 0 );239 $id = $this->_make_attachment( $file, 0 ); 237 240 238 241 // Request a size by array that doesn't exist and is smaller than the 'thumbnail' … … 248 251 public function test_get_intermediate_size_with_small_size_array_fallback() { 249 252 $file = DIR_TESTDATA . '/images/waffles.jpg'; 250 $id = $this->_make_attachment( $file, 0 );251 252 $original = wp_get_attachment_metadata( $id );253 $id = $this->_make_attachment( $file, 0 ); 254 255 $original = wp_get_attachment_metadata( $id ); 253 256 $thumbnail_file = $original['sizes']['thumbnail']['file']; 254 257
Note: See TracChangeset
for help on using the changeset viewer.