Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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/dimensions.php

    r30639 r42343  
    99    function test_400x400_no_crop() {
    1010        // landscape: resize 640x480 to fit 400x400: 400x300
    11         $out = image_resize_dimensions(640, 480, 400, 400, false);
     11        $out = image_resize_dimensions( 640, 480, 400, 400, false );
    1212        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    13         $this->assertEquals( array(0, 0, 0, 0, 400, 300, 640, 480), $out );
     13        $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out );
    1414
    1515        // portrait: resize 480x640 to fit 400x400: 300x400
    16         $out = image_resize_dimensions(480, 640, 400, 400, false);
     16        $out = image_resize_dimensions( 480, 640, 400, 400, false );
    1717        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    18         $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out );
     18        $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    1919    }
    2020
    2121    function test_400x0_no_crop() {
    2222        // landscape: resize 640x480 to fit 400w: 400x300
    23         $out = image_resize_dimensions(640, 480, 400, 0, false);
     23        $out = image_resize_dimensions( 640, 480, 400, 0, false );
    2424        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    25         $this->assertEquals( array(0, 0, 0, 0, 400, 300, 640, 480), $out );
     25        $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out );
    2626
    2727        // portrait: resize 480x640 to fit 400w: 400x533
    28         $out = image_resize_dimensions(480, 640, 400, 0, false);
     28        $out = image_resize_dimensions( 480, 640, 400, 0, false );
    2929        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    30         $this->assertEquals( array(0, 0, 0, 0, 400, 533, 480, 640), $out );
     30        $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out );
    3131    }
    3232
    3333    function test_0x400_no_crop() {
    3434        // landscape: resize 640x480 to fit 400h: 533x400
    35         $out = image_resize_dimensions(640, 480, 0, 400, false);
     35        $out = image_resize_dimensions( 640, 480, 0, 400, false );
    3636        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    37         $this->assertEquals( array(0, 0, 0, 0, 533, 400, 640, 480), $out );
     37        $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out );
    3838
    3939        // portrait: resize 480x640 to fit 400h: 300x400
    40         $out = image_resize_dimensions(480, 640, 0, 400, false);
     40        $out = image_resize_dimensions( 480, 640, 0, 400, false );
    4141        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    42         $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out );
     42        $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    4343    }
    4444
    4545    function test_800x800_no_crop() {
    4646        // landscape: resize 640x480 to fit 800x800
    47         $out = image_resize_dimensions(640, 480, 800, 800, false);
     47        $out = image_resize_dimensions( 640, 480, 800, 800, false );
    4848        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    4949        $this->assertEquals( false, $out );
    5050
    5151        // portrait: resize 480x640 to fit 800x800
    52         $out = image_resize_dimensions(480, 640, 800, 800, false);
     52        $out = image_resize_dimensions( 480, 640, 800, 800, false );
    5353        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    5454        $this->assertEquals( false, $out );
     
    5757    function test_800x0_no_crop() {
    5858        // landscape: resize 640x480 to fit 800w
    59         $out = image_resize_dimensions(640, 480, 800, 0, false);
     59        $out = image_resize_dimensions( 640, 480, 800, 0, false );
    6060        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    6161        $this->assertEquals( false, $out );
    6262
    6363        // portrait: resize 480x640 to fit 800w
    64         $out = image_resize_dimensions(480, 640, 800, 0, false);
     64        $out = image_resize_dimensions( 480, 640, 800, 0, false );
    6565        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    6666        $this->assertEquals( false, $out );
     
    6969    function test_0x800_no_crop() {
    7070        // landscape: resize 640x480 to fit 800h
    71         $out = image_resize_dimensions(640, 480, 0, 800, false);
     71        $out = image_resize_dimensions( 640, 480, 0, 800, false );
    7272        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    7373        $this->assertEquals( false, $out );
    7474
    7575        // portrait: resize 480x640 to fit 800h
    76         $out = image_resize_dimensions(480, 640, 0, 800, false);
     76        $out = image_resize_dimensions( 480, 640, 0, 800, false );
    7777        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    7878        $this->assertEquals( false, $out );
     
    8383    function test_400x400_crop() {
    8484        // landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0)
    85         $out = image_resize_dimensions(640, 480, 400, 400, true);
     85        $out = image_resize_dimensions( 640, 480, 400, 400, true );
    8686        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    87         $this->assertEquals( array(0, 0, 80, 0, 400, 400, 480, 480), $out );
     87        $this->assertEquals( array( 0, 0, 80, 0, 400, 400, 480, 480 ), $out );
    8888
    8989        // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80)
    90         $out = image_resize_dimensions(480, 640, 400, 400, true);
     90        $out = image_resize_dimensions( 480, 640, 400, 400, true );
    9191        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    92         $this->assertEquals( array(0, 0, 0, 80, 400, 400, 480, 480), $out );
     92        $this->assertEquals( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out );
    9393    }
    9494
    9595    function test_400x0_crop() {
    9696        // landscape: resize 640x480 to fit 400w: 400x300
    97         $out = image_resize_dimensions(640, 480, 400, 0, true);
     97        $out = image_resize_dimensions( 640, 480, 400, 0, true );
    9898        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    99         $this->assertEquals( array(0, 0, 0, 0, 400, 300, 640, 480), $out );
     99        $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out );
    100100
    101101        // portrait: resize 480x640 to fit 400w: 400x533
    102         $out = image_resize_dimensions(480, 640, 400, 0, true);
     102        $out = image_resize_dimensions( 480, 640, 400, 0, true );
    103103        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    104         $this->assertEquals( array(0, 0, 0, 0, 400, 533, 480, 640), $out );
     104        $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out );
    105105    }
    106106
    107107    function test_0x400_crop() {
    108108        // landscape: resize 640x480 to fit 400h: 533x400
    109         $out = image_resize_dimensions(640, 480, 0, 400, true);
     109        $out = image_resize_dimensions( 640, 480, 0, 400, true );
    110110        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    111         $this->assertEquals( array(0, 0, 0, 0, 533, 400, 640, 480), $out );
     111        $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out );
    112112
    113113        // portrait: resize 480x640 to fit 400h: 300x400
    114         $out = image_resize_dimensions(480, 640, 0, 400, true);
     114        $out = image_resize_dimensions( 480, 640, 0, 400, true );
    115115        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    116         $this->assertEquals( array(0, 0, 0, 0, 300, 400, 480, 640), $out );
     116        $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    117117    }
    118118
    119119    function test_400x500_crop() {
    120120        // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0)
    121         $out = image_resize_dimensions(640, 480, 400, 500, true);
     121        $out = image_resize_dimensions( 640, 480, 400, 500, true );
    122122        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    123         $this->assertEquals( array(0, 0, 120, 0, 400, 480, 400, 480), $out );
     123        $this->assertEquals( array( 0, 0, 120, 0, 400, 480, 400, 480 ), $out );
    124124
    125125        // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80)
    126         $out = image_resize_dimensions(480, 640, 400, 500, true);
     126        $out = image_resize_dimensions( 480, 640, 400, 500, true );
    127127        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    128         $this->assertEquals( array(0, 0, 0, 20, 400, 500, 480, 600), $out );
     128        $this->assertEquals( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out );
    129129    }
    130130
    131131    function test_640x480() {
    132132        // crop 640x480 to fit 640x480 (no change)
    133         $out = image_resize_dimensions(640, 480, 640, 480, true);
     133        $out = image_resize_dimensions( 640, 480, 640, 480, true );
    134134        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    135         $this->assertEquals( array(0, 0, 0, 0, 640, 480, 640, 480), $out );
     135        $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out );
    136136
    137137        // resize 640x480 to fit 640x480 (no change)
    138         $out = image_resize_dimensions(640, 480, 640, 480, false);
     138        $out = image_resize_dimensions( 640, 480, 640, 480, false );
    139139        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    140         $this->assertEquals( array(0, 0, 0, 0, 640, 480, 640, 480), $out );
     140        $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out );
    141141    }
    142142
     
    147147        // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop
    148148        // src_x = 0 (left), src_y = 0 (top)
    149         $out = image_resize_dimensions(640, 480, 400, 500, array( 'left', 'top' ) );
     149        $out = image_resize_dimensions( 640, 480, 400, 500, array( 'left', 'top' ) );
    150150        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    151         $this->assertEquals( array(0, 0, 0, 0, 400, 480, 400, 480), $out );
     151        $this->assertEquals( array( 0, 0, 0, 0, 400, 480, 400, 480 ), $out );
    152152
    153153        // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop
    154154        // src_x = 0 (left), src_y = 0 (top)
    155         $out = image_resize_dimensions(480, 640, 400, 500, array( 'left', 'top' ) );
     155        $out = image_resize_dimensions( 480, 640, 400, 500, array( 'left', 'top' ) );
    156156        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    157         $this->assertEquals( array(0, 0, 0, 0, 400, 500, 480, 600), $out );
     157        $this->assertEquals( array( 0, 0, 0, 0, 400, 500, 480, 600 ), $out );
    158158
    159159        // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop
    160160        // src_x = 240 (left), src_y = 0 (due to landscape crop)
    161         $out = image_resize_dimensions(640, 480, 400, 500, array( 'right', 'bottom' ) );
     161        $out = image_resize_dimensions( 640, 480, 400, 500, array( 'right', 'bottom' ) );
    162162        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    163         $this->assertEquals( array(0, 0, 240, 0, 400, 480, 400, 480), $out );
     163        $this->assertEquals( array( 0, 0, 240, 0, 400, 480, 400, 480 ), $out );
    164164
    165165        // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop
    166166        // src_x = 0 (due to portrait crop), src_y = 40 (bottom)
    167         $out = image_resize_dimensions(480, 640, 400, 500, array( 'right', 'bottom' ) );
     167        $out = image_resize_dimensions( 480, 640, 400, 500, array( 'right', 'bottom' ) );
    168168        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
    169         $this->assertEquals( array(0, 0, 0, 40, 400, 500, 480, 600), $out );
     169        $this->assertEquals( array( 0, 0, 0, 40, 400, 500, 480, 600 ), $out );
    170170    }
    171171
Note: See TracChangeset for help on using the changeset viewer.