Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/size.php

    r40533 r42343  
    1010    function test_constrain_dims_zero() {
    1111        // no constraint - should have no effect
    12         $out = wp_constrain_dimensions(640, 480, 0, 0);
     12        $out = wp_constrain_dimensions( 640, 480, 0, 0 );
    1313        $this->assertSame( array( 640, 480 ), $out );
    1414
    15         $out = wp_constrain_dimensions(640, 480);
     15        $out = wp_constrain_dimensions( 640, 480 );
    1616        $this->assertSame( array( 640, 480 ), $out );
    1717
    18         $out = wp_constrain_dimensions(0, 0, 0, 0);
     18        $out = wp_constrain_dimensions( 0, 0, 0, 0 );
    1919        $this->assertSame( array( 0, 0 ), $out );
    2020
    21         $out = wp_constrain_dimensions(465, 700, 177, 177);
     21        $out = wp_constrain_dimensions( 465, 700, 177, 177 );
    2222        $this->assertSame( array( 118, 177 ), $out );
    2323    }
     
    2525    function test_constrain_dims_smaller() {
    2626        // image size is smaller than the constraint - no effect
    27         $out = wp_constrain_dimensions(500, 600, 1024, 768);
    28         $this->assertSame( array( 500, 600 ), $out );
    29 
    30         $out = wp_constrain_dimensions(500, 600, 0, 768);
    31         $this->assertSame( array( 500, 600 ), $out );
    32 
    33         $out = wp_constrain_dimensions(500, 600, 1024, 0);
     27        $out = wp_constrain_dimensions( 500, 600, 1024, 768 );
     28        $this->assertSame( array( 500, 600 ), $out );
     29
     30        $out = wp_constrain_dimensions( 500, 600, 0, 768 );
     31        $this->assertSame( array( 500, 600 ), $out );
     32
     33        $out = wp_constrain_dimensions( 500, 600, 1024, 0 );
    3434        $this->assertSame( array( 500, 600 ), $out );
    3535    }
     
    3737    function test_constrain_dims_equal() {
    3838        // image size is equal to the constraint - no effect
    39         $out = wp_constrain_dimensions(1024, 768, 1024, 768);
     39        $out = wp_constrain_dimensions( 1024, 768, 1024, 768 );
    4040        $this->assertSame( array( 1024, 768 ), $out );
    4141
    42         $out = wp_constrain_dimensions(1024, 768, 0, 768);
     42        $out = wp_constrain_dimensions( 1024, 768, 0, 768 );
    4343        $this->assertSame( array( 1024, 768 ), $out );
    4444
    45         $out = wp_constrain_dimensions(1024, 768, 1024, 0);
     45        $out = wp_constrain_dimensions( 1024, 768, 1024, 0 );
    4646        $this->assertSame( array( 1024, 768 ), $out );
    4747    }
     
    4949    function test_constrain_dims_larger() {
    5050        // image size is larger than the constraint - result should be constrained
    51         $out = wp_constrain_dimensions(1024, 768, 500, 600);
    52         $this->assertSame( array( 500, 375 ), $out );
    53 
    54         $out = wp_constrain_dimensions(1024, 768, 0, 600);
     51        $out = wp_constrain_dimensions( 1024, 768, 500, 600 );
     52        $this->assertSame( array( 500, 375 ), $out );
     53
     54        $out = wp_constrain_dimensions( 1024, 768, 0, 600 );
    5555        $this->assertSame( array( 800, 600 ), $out );
    5656
    57         $out = wp_constrain_dimensions(1024, 768, 500, 0);
     57        $out = wp_constrain_dimensions( 1024, 768, 500, 0 );
    5858        $this->assertSame( array( 500, 375 ), $out );
    5959
    6060        // also try a portrait oriented image
    61         $out = wp_constrain_dimensions(300, 800, 500, 600);
     61        $out = wp_constrain_dimensions( 300, 800, 500, 600 );
    6262        $this->assertSame( array( 225, 600 ), $out );
    6363
    64         $out = wp_constrain_dimensions(300, 800, 0, 600);
     64        $out = wp_constrain_dimensions( 300, 800, 0, 600 );
    6565        $this->assertSame( array( 225, 600 ), $out );
    6666
    67         $out = wp_constrain_dimensions(300, 800, 200, 0);
     67        $out = wp_constrain_dimensions( 300, 800, 200, 0 );
    6868        $this->assertSame( array( 200, 533 ), $out );
    6969    }
     
    7171    function test_constrain_dims_boundary() {
    7272        // one dimension is larger than the constraint, one smaller - result should be constrained
    73         $out = wp_constrain_dimensions(1024, 768, 500, 800);
    74         $this->assertSame( array( 500, 375 ), $out );
    75 
    76         $out = wp_constrain_dimensions(1024, 768, 2000, 700);
     73        $out = wp_constrain_dimensions( 1024, 768, 500, 800 );
     74        $this->assertSame( array( 500, 375 ), $out );
     75
     76        $out = wp_constrain_dimensions( 1024, 768, 2000, 700 );
    7777        $this->assertSame( array( 933, 700 ), $out );
    7878
    7979        // portrait
    80         $out = wp_constrain_dimensions(768, 1024, 800, 500);
     80        $out = wp_constrain_dimensions( 768, 1024, 800, 500 );
    8181        $this->assertSame( array( 375, 500 ), $out );
    8282
    83         $out = wp_constrain_dimensions(768, 1024, 2000, 700);
     83        $out = wp_constrain_dimensions( 768, 1024, 2000, 700 );
    8484        $this->assertSame( array( 525, 700 ), $out );
    8585    }
     
    8989     */
    9090    function test_shrink_dimensions_default() {
    91         $out = wp_shrink_dimensions(640, 480);
     91        $out = wp_shrink_dimensions( 640, 480 );
    9292        $this->assertSame( array( 128, 96 ), $out );
    9393
    94         $out = wp_shrink_dimensions(480, 640);
     94        $out = wp_shrink_dimensions( 480, 640 );
    9595        $this->assertSame( array( 72, 96 ), $out );
    9696    }
     
    101101    function test_shrink_dimensions_smaller() {
    102102        // image size is smaller than the constraint - no effect
    103         $out = wp_shrink_dimensions(500, 600, 1024, 768);
    104         $this->assertSame( array( 500, 600 ), $out );
    105 
    106         $out = wp_shrink_dimensions(600, 500, 1024, 768);
     103        $out = wp_shrink_dimensions( 500, 600, 1024, 768 );
     104        $this->assertSame( array( 500, 600 ), $out );
     105
     106        $out = wp_shrink_dimensions( 600, 500, 1024, 768 );
    107107        $this->assertSame( array( 600, 500 ), $out );
    108108    }
     
    113113    function test_shrink_dimensions_equal() {
    114114        // image size is equal to the constraint - no effect
    115         $out = wp_shrink_dimensions(500, 600, 500, 600);
    116         $this->assertSame( array( 500, 600 ), $out );
    117 
    118         $out = wp_shrink_dimensions(600, 500, 600, 500);
     115        $out = wp_shrink_dimensions( 500, 600, 500, 600 );
     116        $this->assertSame( array( 500, 600 ), $out );
     117
     118        $out = wp_shrink_dimensions( 600, 500, 600, 500 );
    119119        $this->assertSame( array( 600, 500 ), $out );
    120120    }
     
    125125    function test_shrink_dimensions_larger() {
    126126        // image size is larger than the constraint - result should be constrained
    127         $out = wp_shrink_dimensions(1024, 768, 500, 600);
    128         $this->assertSame( array( 500, 375 ), $out );
    129 
    130         $out = wp_shrink_dimensions(300, 800, 500, 600);
     127        $out = wp_shrink_dimensions( 1024, 768, 500, 600 );
     128        $this->assertSame( array( 500, 375 ), $out );
     129
     130        $out = wp_shrink_dimensions( 300, 800, 500, 600 );
    131131        $this->assertSame( array( 225, 600 ), $out );
    132132    }
     
    137137    function test_shrink_dimensions_boundary() {
    138138        // one dimension is larger than the constraint, one smaller - result should be constrained
    139         $out = wp_shrink_dimensions(1024, 768, 500, 800);
    140         $this->assertSame( array( 500, 375 ), $out );
    141 
    142         $out = wp_shrink_dimensions(1024, 768, 2000, 700);
     139        $out = wp_shrink_dimensions( 1024, 768, 500, 800 );
     140        $this->assertSame( array( 500, 375 ), $out );
     141
     142        $out = wp_shrink_dimensions( 1024, 768, 2000, 700 );
    143143        $this->assertSame( array( 933, 700 ), $out );
    144144
    145145        // portrait
    146         $out = wp_shrink_dimensions(768, 1024, 800, 500);
     146        $out = wp_shrink_dimensions( 768, 1024, 800, 500 );
    147147        $this->assertSame( array( 375, 500 ), $out );
    148148
    149         $out = wp_shrink_dimensions(768, 1024, 2000, 700);
     149        $out = wp_shrink_dimensions( 768, 1024, 2000, 700 );
    150150        $this->assertSame( array( 525, 700 ), $out );
    151151    }
    152152
    153153    function test_constrain_size_for_editor_thumb() {
    154         $out = image_constrain_size_for_editor(600, 400, 'thumb');
     154        $out = image_constrain_size_for_editor( 600, 400, 'thumb' );
    155155        $this->assertSame( array( 150, 100 ), $out );
    156156
    157         $out = image_constrain_size_for_editor(64, 64, 'thumb');
     157        $out = image_constrain_size_for_editor( 64, 64, 'thumb' );
    158158        $this->assertSame( array( 64, 64 ), $out );
    159159    }
     
    166166
    167167        $content_width = 0;
    168         update_option('medium_size_w', 500);
    169         update_option('medium_size_h', 0);
    170 
    171         $out = image_constrain_size_for_editor(600, 400, 'medium');
     168        update_option( 'medium_size_w', 500 );
     169        update_option( 'medium_size_h', 0 );
     170
     171        $out = image_constrain_size_for_editor( 600, 400, 'medium' );
    172172        $this->assertSame( array( 500, 333 ), $out );
    173173
    174         $out = image_constrain_size_for_editor(400, 600, 'medium');
     174        $out = image_constrain_size_for_editor( 400, 600, 'medium' );
    175175        $this->assertSame( array( 400, 600 ), $out );
    176176
    177         $out = image_constrain_size_for_editor(64, 64, 'medium');
     177        $out = image_constrain_size_for_editor( 64, 64, 'medium' );
    178178        $this->assertSame( array( 64, 64 ), $out );
    179179
    180180        // content_width should be ignored
    181181        $content_width = 350;
    182         $out = image_constrain_size_for_editor(600, 400, 'medium');
     182        $out           = image_constrain_size_for_editor( 600, 400, 'medium' );
    183183        $this->assertSame( array( 500, 333 ), $out );
    184184
     
    192192
    193193        $content_width = 400;
    194         $out = image_constrain_size_for_editor(600, 400, 'full');
     194        $out           = image_constrain_size_for_editor( 600, 400, 'full' );
    195195        $this->assertSame( array( 600, 400 ), $out );
    196196
    197         $out = image_constrain_size_for_editor(64, 64, 'full');
     197        $out = image_constrain_size_for_editor( 64, 64, 'full' );
    198198        $this->assertSame( array( 64, 64 ), $out );
    199199
     
    201201        $content_width = 0;
    202202
    203         $out = image_constrain_size_for_editor(600, 400, 'full');
     203        $out = image_constrain_size_for_editor( 600, 400, 'full' );
    204204        $this->assertSame( array( 600, 400 ), $out );
    205205
    206         $out = image_constrain_size_for_editor(64, 64, 'full');
     206        $out = image_constrain_size_for_editor( 64, 64, 'full' );
    207207        $this->assertSame( array( 64, 64 ), $out );
    208208
Note: See TracChangeset for help on using the changeset viewer.