Changeset 34775
- Timestamp:
- 10/02/2015 02:13:15 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/intermediate_size.php
r33846 r34775 215 215 216 216 /** 217 * @ticket 17626 218 */ 217 * @ticket 17626 218 * @ticket 34087 219 */ 219 220 function test_get_intermediate_sizes_by_array_zero_width() { 220 // Generate random height221 $ random_h = rand( 200, 300 );221 // 202 is the smallest height that will trigger a miss for 'false-height'. 222 $height = 202; 222 223 223 224 // Only one dimention match shouldn't return false positive (see: 17626) 224 add_image_size( 'test-size', 0, $ random_h, false );225 add_image_size( 'false-height', 300, $ random_h, true );225 add_image_size( 'test-size', 0, $height, false ); 226 add_image_size( 'false-height', 300, $height, true ); 226 227 227 228 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 229 230 230 231 $original = wp_get_attachment_metadata( $id ); 231 $image_h = $ random_h;232 $image_h = $height; 232 233 $image_w = round( ( $image_h / $original['height'] ) * $original['width'] ); 233 234 234 235 // look for a size by array that exists 235 236 // note: staying larger than 300px to miss default medium crop 236 $image = image_get_intermediate_size( $id, array( 0, $ random_h) );237 $image = image_get_intermediate_size( $id, array( 0, $height ) ); 237 238 238 239 // test for the expected string because the array will by definition … … 244 245 remove_image_size( 'false-height' ); 245 246 } 247 248 /** 249 * @ticket 17626 250 * @ticket 34087 251 */ 252 public function test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio() { 253 // Original is 600x400. 300x201 is close enough to match. 254 $width = 300; 255 $height = 201; 256 add_image_size( 'off-by-one', $width, $height, true ); 257 258 $file = DIR_TESTDATA . '/images/waffles.jpg'; 259 $id = $this->_make_attachment( $file, 0 ); 260 261 $original = wp_get_attachment_metadata( $id ); 262 $image_h = $height; 263 $image_w = round( ( $image_h / $original['height'] ) * $original['width'] ); 264 265 // look for a size by array that exists 266 // note: staying larger than 300px to miss default medium crop 267 $image = image_get_intermediate_size( $id, array( 0, $height ) ); 268 269 $this->assertTrue( strpos( $image['file'], $width . 'x' . $height ) > 0 ); 270 271 // cleanup 272 remove_image_size( 'off-by-one' ); 273 } 246 274 }
Note: See TracChangeset
for help on using the changeset viewer.