Make WordPress Core

Changeset 407 in tests for wp-testcase/test_image.php


Ignore:
Timestamp:
08/04/2011 08:38:26 PM (15 years ago)
Author:
ryan
Message:

Pinking shears

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_image.php

    r402 r407  
    8080
    8181        }
    82        
     82
    8383        function test_exif_error() {
    8484                if (!is_callable('wp_read_image_metadata'))
    8585                        $this->markTestSkipped();
    86                        
     86
    8787                $this->knownWPBug(6571);
    88                        
     88
    8989                // http://trac.wordpress.org/ticket/6571
    9090                // this triggers a warning mesage when reading the exif block
     
    106106                if (!is_callable('wp_read_image_metadata'))
    107107                        $this->markTestSkipped();
    108                        
     108
    109109                // no exif data in this image (from burningwell.org)
    110110                $out = wp_read_image_metadata(DIR_TESTDATA.'/images/canola.jpg');
     
    121121                $this->assertEquals('', $out['title']);
    122122        }
    123        
     123
    124124}
    125125
     
    128128                if (!is_callable('wp_constrain_dimensions'))
    129129                        $this->markTestSkipped();
    130                        
     130
    131131                // no constraint - should have no effect
    132132                $out = wp_constrain_dimensions(640, 480, 0, 0);
     
    135135                $out = wp_constrain_dimensions(640, 480);
    136136                $this->assertEquals(array(640, 480), $out);
    137                
     137
    138138                $out = wp_constrain_dimensions(0, 0, 0, 0);
    139139                $this->assertEquals(array(0, 0), $out);
    140140        }
    141        
     141
    142142        function test_constrain_dims_smaller() {
    143143                if (!is_callable('wp_constrain_dimensions'))
    144144                        $this->markTestSkipped();
    145                        
     145
    146146                // image size is smaller than the constraint - no effect
    147147                $out = wp_constrain_dimensions(500, 600, 1024, 768);
     
    158158                if (!is_callable('wp_constrain_dimensions'))
    159159                        $this->markTestSkipped();
    160                        
     160
    161161                // image size is equal to the constraint - no effect
    162162                $out = wp_constrain_dimensions(1024, 768, 1024, 768);
     
    169169                $this->assertequals(array(1024, 768), $out);
    170170        }
    171        
     171
    172172        function test_constrain_dims_larger() {
    173173                if (!is_callable('wp_constrain_dimensions'))
    174174                        $this->markTestSkipped();
    175                        
     175
    176176                // image size is larger than the constraint - result should be constrained
    177177                $out = wp_constrain_dimensions(1024, 768, 500, 600);
     
    183183                $out = wp_constrain_dimensions(1024, 768, 500, 0);
    184184                $this->assertequals(array(500, 375), $out);
    185                
     185
    186186                // also try a portrait oriented image
    187187                $out = wp_constrain_dimensions(300, 800, 500, 600);
     
    198198                if (!is_callable('wp_constrain_dimensions'))
    199199                        $this->markTestSkipped();
    200                        
     200
    201201                // one dimension is larger than the constraint, one smaller - result should be constrained
    202202                $out = wp_constrain_dimensions(1024, 768, 500, 800);
    203203                $this->assertequals(array(500, 375), $out);
    204                
     204
    205205                $out = wp_constrain_dimensions(1024, 768, 2000, 700);
    206206                $this->assertequals(array(933, 700), $out);
     
    209209                $out = wp_constrain_dimensions(768, 1024, 800, 500);
    210210                $this->assertequals(array(375, 500), $out);
    211                
     211
    212212                $out = wp_constrain_dimensions(768, 1024, 2000, 700);
    213213                $this->assertequals(array(525, 700), $out);
    214214        }
    215        
     215
    216216        function test_shrink_dimensions_default() {
    217217                $out = wp_shrink_dimensions(640, 480);
     
    253253                $out = wp_shrink_dimensions(1024, 768, 500, 800);
    254254                $this->assertequals(array(500, 375), $out);
    255                
     255
    256256                $out = wp_shrink_dimensions(1024, 768, 2000, 700);
    257257                $this->assertequals(array(933, 700), $out);
     
    260260                $out = wp_shrink_dimensions(768, 1024, 800, 500);
    261261                $this->assertequals(array(375, 500), $out);
    262                
     262
    263263                $out = wp_shrink_dimensions(768, 1024, 2000, 700);
    264264                $this->assertequals(array(525, 700), $out);
    265265        }
    266        
     266
    267267        function test_constrain_size_for_editor_thumb() {
    268268                $out = image_constrain_size_for_editor(600, 400, 'thumb');
    269269                $this->assertEquals(array(150, 100), $out);
    270                
     270
    271271                $out = image_constrain_size_for_editor(64, 64, 'thumb');
    272272                $this->assertEquals(array(64, 64), $out);
     
    279279                update_option('medium_size_w', 500);
    280280                update_option('medium_size_h', 0);
    281                
     281
    282282                $out = image_constrain_size_for_editor(600, 400, 'medium');
    283283                $this->assertEquals(array(500, 333), $out);
     
    285285                $out = image_constrain_size_for_editor(400, 600, 'medium');
    286286                $this->assertEquals(array(400, 600), $out);
    287                
     287
    288288                $out = image_constrain_size_for_editor(64, 64, 'medium');
    289289                $this->assertEquals(array(64, 64), $out);
    290                
     290
    291291                // content_width should be ignored
    292292                $content_width = 350;
     
    300300                $out = image_constrain_size_for_editor(600, 400, 'full');
    301301                $this->assertEquals(array(600, 400), $out);
    302                
     302
    303303                $out = image_constrain_size_for_editor(64, 64, 'full');
    304304                $this->assertEquals(array(64, 64), $out);
    305                
     305
    306306                // content_width default is 500
    307307                $content_width = 0;
     
    309309                $out = image_constrain_size_for_editor(600, 400, 'full');
    310310                $this->assertEquals(array(600, 400), $out);
    311                
     311
    312312                $out = image_constrain_size_for_editor(64, 64, 'full');
    313313                $this->assertEquals(array(64, 64), $out);
    314         }
    315        
     314<<<<<<< .mine
     315
     316=======
     317>>>>>>> .r406
     318        }
     319
    316320}
    317321
     
    328332                $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out );
    329333        }
    330        
     334
    331335        function test_400x0_no_crop() {
    332336                // landscape: resize 640x480 to fit 400w: 400x300
     
    402406                $this->assertEquals( array(0, 0, 0, 80, 400, 400, 480, 480), $out );
    403407        }
    404        
     408
    405409        function test_400x0_crop() {
    406410                // landscape: resize 640x480 to fit 400w: 400x300
     
    426430                $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out );
    427431        }
    428        
     432
    429433        function test_400x500_crop() {
    430434                // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0)
     
    438442                $this->assertEquals( array(0, 0, 0, 20, 400, 500, 480, 600), $out );
    439443        }
    440        
     444
    441445}
    442446
     
    480484                $this->assertEquals( 'error_getting_dimensions', $image->get_error_code() );
    481485        }
    482        
     486
    483487        function test_resize_thumb_128x96() {
    484488                $image = image_resize( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 128, 96 );
     
    571575                        'test-image.jpg',
    572576                        );
    573                        
     577
    574578                foreach ($files as $file) {
    575579                        $this->assertTrue( file_is_valid_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return true" );
    576580                }
    577581        }
    578        
     582
    579583        function test_is_image_negative() {
    580584                // these are actually image files but aren't recognized or usable by php
     
    584588                        'test-image.sgi',
    585589                        );
    586                        
     590
    587591                foreach ($files as $file) {
    588592                        $this->assertFalse( file_is_valid_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return false" );
    589593                }
    590594        }
    591        
     595
    592596        function test_is_displayable_image_positive() {
    593597                // these are all usable in typical web browsers
     
    597601                        'test-image.jpg',
    598602                        );
    599                        
     603
    600604                foreach ($files as $file) {
    601605                        $this->assertTrue( file_is_displayable_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return true" );
    602606                }
    603607        }
    604        
     608
    605609        function test_is_displayable_image_negative() {
    606610                // these are image files but aren't suitable for web pages because of compatibility or size issues
     
    623627                }
    624628        }
    625        
    626        
    627        
     629
     630
     631
    628632}
    629633
Note: See TracChangeset for help on using the changeset viewer.