Changeset 407 in tests for wp-testcase/test_image.php
- Timestamp:
- 08/04/2011 08:38:26 PM (15 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_image.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_image.php
r402 r407 80 80 81 81 } 82 82 83 83 function test_exif_error() { 84 84 if (!is_callable('wp_read_image_metadata')) 85 85 $this->markTestSkipped(); 86 86 87 87 $this->knownWPBug(6571); 88 88 89 89 // http://trac.wordpress.org/ticket/6571 90 90 // this triggers a warning mesage when reading the exif block … … 106 106 if (!is_callable('wp_read_image_metadata')) 107 107 $this->markTestSkipped(); 108 108 109 109 // no exif data in this image (from burningwell.org) 110 110 $out = wp_read_image_metadata(DIR_TESTDATA.'/images/canola.jpg'); … … 121 121 $this->assertEquals('', $out['title']); 122 122 } 123 123 124 124 } 125 125 … … 128 128 if (!is_callable('wp_constrain_dimensions')) 129 129 $this->markTestSkipped(); 130 130 131 131 // no constraint - should have no effect 132 132 $out = wp_constrain_dimensions(640, 480, 0, 0); … … 135 135 $out = wp_constrain_dimensions(640, 480); 136 136 $this->assertEquals(array(640, 480), $out); 137 137 138 138 $out = wp_constrain_dimensions(0, 0, 0, 0); 139 139 $this->assertEquals(array(0, 0), $out); 140 140 } 141 141 142 142 function test_constrain_dims_smaller() { 143 143 if (!is_callable('wp_constrain_dimensions')) 144 144 $this->markTestSkipped(); 145 145 146 146 // image size is smaller than the constraint - no effect 147 147 $out = wp_constrain_dimensions(500, 600, 1024, 768); … … 158 158 if (!is_callable('wp_constrain_dimensions')) 159 159 $this->markTestSkipped(); 160 160 161 161 // image size is equal to the constraint - no effect 162 162 $out = wp_constrain_dimensions(1024, 768, 1024, 768); … … 169 169 $this->assertequals(array(1024, 768), $out); 170 170 } 171 171 172 172 function test_constrain_dims_larger() { 173 173 if (!is_callable('wp_constrain_dimensions')) 174 174 $this->markTestSkipped(); 175 175 176 176 // image size is larger than the constraint - result should be constrained 177 177 $out = wp_constrain_dimensions(1024, 768, 500, 600); … … 183 183 $out = wp_constrain_dimensions(1024, 768, 500, 0); 184 184 $this->assertequals(array(500, 375), $out); 185 185 186 186 // also try a portrait oriented image 187 187 $out = wp_constrain_dimensions(300, 800, 500, 600); … … 198 198 if (!is_callable('wp_constrain_dimensions')) 199 199 $this->markTestSkipped(); 200 200 201 201 // one dimension is larger than the constraint, one smaller - result should be constrained 202 202 $out = wp_constrain_dimensions(1024, 768, 500, 800); 203 203 $this->assertequals(array(500, 375), $out); 204 204 205 205 $out = wp_constrain_dimensions(1024, 768, 2000, 700); 206 206 $this->assertequals(array(933, 700), $out); … … 209 209 $out = wp_constrain_dimensions(768, 1024, 800, 500); 210 210 $this->assertequals(array(375, 500), $out); 211 211 212 212 $out = wp_constrain_dimensions(768, 1024, 2000, 700); 213 213 $this->assertequals(array(525, 700), $out); 214 214 } 215 215 216 216 function test_shrink_dimensions_default() { 217 217 $out = wp_shrink_dimensions(640, 480); … … 253 253 $out = wp_shrink_dimensions(1024, 768, 500, 800); 254 254 $this->assertequals(array(500, 375), $out); 255 255 256 256 $out = wp_shrink_dimensions(1024, 768, 2000, 700); 257 257 $this->assertequals(array(933, 700), $out); … … 260 260 $out = wp_shrink_dimensions(768, 1024, 800, 500); 261 261 $this->assertequals(array(375, 500), $out); 262 262 263 263 $out = wp_shrink_dimensions(768, 1024, 2000, 700); 264 264 $this->assertequals(array(525, 700), $out); 265 265 } 266 266 267 267 function test_constrain_size_for_editor_thumb() { 268 268 $out = image_constrain_size_for_editor(600, 400, 'thumb'); 269 269 $this->assertEquals(array(150, 100), $out); 270 270 271 271 $out = image_constrain_size_for_editor(64, 64, 'thumb'); 272 272 $this->assertEquals(array(64, 64), $out); … … 279 279 update_option('medium_size_w', 500); 280 280 update_option('medium_size_h', 0); 281 281 282 282 $out = image_constrain_size_for_editor(600, 400, 'medium'); 283 283 $this->assertEquals(array(500, 333), $out); … … 285 285 $out = image_constrain_size_for_editor(400, 600, 'medium'); 286 286 $this->assertEquals(array(400, 600), $out); 287 287 288 288 $out = image_constrain_size_for_editor(64, 64, 'medium'); 289 289 $this->assertEquals(array(64, 64), $out); 290 290 291 291 // content_width should be ignored 292 292 $content_width = 350; … … 300 300 $out = image_constrain_size_for_editor(600, 400, 'full'); 301 301 $this->assertEquals(array(600, 400), $out); 302 302 303 303 $out = image_constrain_size_for_editor(64, 64, 'full'); 304 304 $this->assertEquals(array(64, 64), $out); 305 305 306 306 // content_width default is 500 307 307 $content_width = 0; … … 309 309 $out = image_constrain_size_for_editor(600, 400, 'full'); 310 310 $this->assertEquals(array(600, 400), $out); 311 311 312 312 $out = image_constrain_size_for_editor(64, 64, 'full'); 313 313 $this->assertEquals(array(64, 64), $out); 314 } 315 314 <<<<<<< .mine 315 316 ======= 317 >>>>>>> .r406 318 } 319 316 320 } 317 321 … … 328 332 $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out ); 329 333 } 330 334 331 335 function test_400x0_no_crop() { 332 336 // landscape: resize 640x480 to fit 400w: 400x300 … … 402 406 $this->assertEquals( array(0, 0, 0, 80, 400, 400, 480, 480), $out ); 403 407 } 404 408 405 409 function test_400x0_crop() { 406 410 // landscape: resize 640x480 to fit 400w: 400x300 … … 426 430 $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out ); 427 431 } 428 432 429 433 function test_400x500_crop() { 430 434 // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0) … … 438 442 $this->assertEquals( array(0, 0, 0, 20, 400, 500, 480, 600), $out ); 439 443 } 440 444 441 445 } 442 446 … … 480 484 $this->assertEquals( 'error_getting_dimensions', $image->get_error_code() ); 481 485 } 482 486 483 487 function test_resize_thumb_128x96() { 484 488 $image = image_resize( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 128, 96 ); … … 571 575 'test-image.jpg', 572 576 ); 573 577 574 578 foreach ($files as $file) { 575 579 $this->assertTrue( file_is_valid_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return true" ); 576 580 } 577 581 } 578 582 579 583 function test_is_image_negative() { 580 584 // these are actually image files but aren't recognized or usable by php … … 584 588 'test-image.sgi', 585 589 ); 586 590 587 591 foreach ($files as $file) { 588 592 $this->assertFalse( file_is_valid_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return false" ); 589 593 } 590 594 } 591 595 592 596 function test_is_displayable_image_positive() { 593 597 // these are all usable in typical web browsers … … 597 601 'test-image.jpg', 598 602 ); 599 603 600 604 foreach ($files as $file) { 601 605 $this->assertTrue( file_is_displayable_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return true" ); 602 606 } 603 607 } 604 608 605 609 function test_is_displayable_image_negative() { 606 610 // these are image files but aren't suitable for web pages because of compatibility or size issues … … 623 627 } 624 628 } 625 626 627 629 630 631 628 632 } 629 633
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)