Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

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

    r46586 r47122  
    88class Tests_Image_Dimensions extends WP_UnitTestCase {
    99    function test_400x400_no_crop() {
    10         // landscape: resize 640x480 to fit 400x400: 400x300
     10        // Landscape: resize 640x480 to fit 400x400: 400x300.
    1111        $out = image_resize_dimensions( 640, 480, 400, 400, false );
    12         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     12        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    1313        $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out );
    1414
    15         // portrait: resize 480x640 to fit 400x400: 300x400
     15        // Portrait: resize 480x640 to fit 400x400: 300x400.
    1616        $out = image_resize_dimensions( 480, 640, 400, 400, false );
    17         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     17        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    1818        $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    1919    }
    2020
    2121    function test_400x0_no_crop() {
    22         // landscape: resize 640x480 to fit 400w: 400x300
     22        // Landscape: resize 640x480 to fit 400w: 400x300.
    2323        $out = image_resize_dimensions( 640, 480, 400, 0, false );
    24         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     24        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    2525        $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out );
    2626
    27         // portrait: resize 480x640 to fit 400w: 400x533
     27        // Portrait: resize 480x640 to fit 400w: 400x533.
    2828        $out = image_resize_dimensions( 480, 640, 400, 0, false );
    29         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     29        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    3030        $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out );
    3131    }
    3232
    3333    function test_0x400_no_crop() {
    34         // landscape: resize 640x480 to fit 400h: 533x400
     34        // Landscape: resize 640x480 to fit 400h: 533x400.
    3535        $out = image_resize_dimensions( 640, 480, 0, 400, false );
    36         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     36        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    3737        $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out );
    3838
    39         // portrait: resize 480x640 to fit 400h: 300x400
     39        // Portrait: resize 480x640 to fit 400h: 300x400.
    4040        $out = image_resize_dimensions( 480, 640, 0, 400, false );
    41         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     41        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    4242        $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    4343    }
    4444
    4545    function test_800x800_no_crop() {
    46         // landscape: resize 640x480 to fit 800x800
     46        // Landscape: resize 640x480 to fit 800x800.
    4747        $out = image_resize_dimensions( 640, 480, 800, 800, false );
    48         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     48        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    4949        $this->assertEquals( false, $out );
    5050
    51         // portrait: resize 480x640 to fit 800x800
     51        // Portrait: resize 480x640 to fit 800x800.
    5252        $out = image_resize_dimensions( 480, 640, 800, 800, false );
    53         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     53        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    5454        $this->assertEquals( false, $out );
    5555    }
    5656
    5757    function test_800x0_no_crop() {
    58         // landscape: resize 640x480 to fit 800w
     58        // Landscape: resize 640x480 to fit 800w.
    5959        $out = image_resize_dimensions( 640, 480, 800, 0, false );
    60         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     60        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    6161        $this->assertEquals( false, $out );
    6262
    63         // portrait: resize 480x640 to fit 800w
     63        // Portrait: resize 480x640 to fit 800w.
    6464        $out = image_resize_dimensions( 480, 640, 800, 0, false );
    65         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     65        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    6666        $this->assertEquals( false, $out );
    6767    }
    6868
    6969    function test_0x800_no_crop() {
    70         // landscape: resize 640x480 to fit 800h
     70        // Landscape: resize 640x480 to fit 800h.
    7171        $out = image_resize_dimensions( 640, 480, 0, 800, false );
    72         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     72        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    7373        $this->assertEquals( false, $out );
    7474
    75         // portrait: resize 480x640 to fit 800h
     75        // Portrait: resize 480x640 to fit 800h.
    7676        $out = image_resize_dimensions( 480, 640, 0, 800, false );
    77         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     77        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    7878        $this->assertEquals( false, $out );
    7979    }
    8080
    81     // cropped versions
     81    // Cropped versions.
    8282
    8383    function test_400x400_crop() {
    84         // landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0)
     84        // Landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0).
    8585        $out = image_resize_dimensions( 640, 480, 400, 400, true );
    86         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     86        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    8787        $this->assertEquals( array( 0, 0, 80, 0, 400, 400, 480, 480 ), $out );
    8888
    89         // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80)
     89        // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80).
    9090        $out = image_resize_dimensions( 480, 640, 400, 400, true );
    91         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     91        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    9292        $this->assertEquals( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out );
    9393    }
    9494
    9595    function test_400x0_crop() {
    96         // landscape: resize 640x480 to fit 400w: 400x300
     96        // Landscape: resize 640x480 to fit 400w: 400x300.
    9797        $out = image_resize_dimensions( 640, 480, 400, 0, true );
    98         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     98        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    9999        $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out );
    100100
    101         // portrait: resize 480x640 to fit 400w: 400x533
     101        // Portrait: resize 480x640 to fit 400w: 400x533.
    102102        $out = image_resize_dimensions( 480, 640, 400, 0, true );
    103         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     103        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    104104        $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out );
    105105    }
    106106
    107107    function test_0x400_crop() {
    108         // landscape: resize 640x480 to fit 400h: 533x400
     108        // Landscape: resize 640x480 to fit 400h: 533x400.
    109109        $out = image_resize_dimensions( 640, 480, 0, 400, true );
    110         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     110        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    111111        $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out );
    112112
    113         // portrait: resize 480x640 to fit 400h: 300x400
     113        // Portrait: resize 480x640 to fit 400h: 300x400.
    114114        $out = image_resize_dimensions( 480, 640, 0, 400, true );
    115         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     115        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    116116        $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    117117    }
    118118
    119119    function test_400x500_crop() {
    120         // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0)
     120        // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0).
    121121        $out = image_resize_dimensions( 640, 480, 400, 500, true );
    122         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     122        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    123123        $this->assertEquals( array( 0, 0, 120, 0, 400, 480, 400, 480 ), $out );
    124124
    125         // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80)
     125        // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80).
    126126        $out = image_resize_dimensions( 480, 640, 400, 500, true );
    127         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     127        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    128128        $this->assertEquals( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out );
    129129    }
    130130
    131131    function test_640x480() {
    132         // crop 640x480 to fit 640x480 (no change)
     132        // Crop 640x480 to fit 640x480 (no change).
    133133        $out = image_resize_dimensions( 640, 480, 640, 480, true );
    134134        $this->assertFalse( $out );
    135135
    136         // resize 640x480 to fit 640x480 (no change)
     136        // Resize 640x480 to fit 640x480 (no change).
    137137        $out = image_resize_dimensions( 640, 480, 640, 480, false );
    138138        $this->assertFalse( $out );
     
    141141        add_filter( 'wp_image_resize_identical_dimensions', '__return_true' );
    142142
    143         // crop 640x480 to fit 640x480 (no change)
     143        // Crop 640x480 to fit 640x480 (no change).
    144144        $out = image_resize_dimensions( 640, 480, 640, 480, true );
    145         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     145        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    146146        $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out );
    147147
    148         // resize 640x480 to fit 640x480 (no change)
     148        // Resize 640x480 to fit 640x480 (no change).
    149149        $out = image_resize_dimensions( 640, 480, 640, 480, false );
    150         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     150        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    151151        $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out );
    152152
     
    158158     */
    159159    function test_crop_anchors() {
    160         // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop
    161         // src_x = 0 (left), src_y = 0 (top)
     160        // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop.
     161        // src_x = 0 (left), src_y = 0 (top).
    162162        $out = image_resize_dimensions( 640, 480, 400, 500, array( 'left', 'top' ) );
    163         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     163        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    164164        $this->assertEquals( array( 0, 0, 0, 0, 400, 480, 400, 480 ), $out );
    165165
    166         // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop
    167         // src_x = 0 (left), src_y = 0 (top)
     166        // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop.
     167        // src_x = 0 (left), src_y = 0 (top).
    168168        $out = image_resize_dimensions( 480, 640, 400, 500, array( 'left', 'top' ) );
    169         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     169        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    170170        $this->assertEquals( array( 0, 0, 0, 0, 400, 500, 480, 600 ), $out );
    171171
    172         // landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop
    173         // src_x = 240 (left), src_y = 0 (due to landscape crop)
     172        // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop.
     173        // src_x = 240 (left), src_y = 0 (due to landscape crop).
    174174        $out = image_resize_dimensions( 640, 480, 400, 500, array( 'right', 'bottom' ) );
    175         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     175        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    176176        $this->assertEquals( array( 0, 0, 240, 0, 400, 480, 400, 480 ), $out );
    177177
    178         // portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop
    179         // src_x = 0 (due to portrait crop), src_y = 40 (bottom)
     178        // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop.
     179        // src_x = 0 (due to portrait crop), src_y = 40 (bottom).
    180180        $out = image_resize_dimensions( 480, 640, 400, 500, array( 'right', 'bottom' ) );
    181         // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h
     181        // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h.
    182182        $this->assertEquals( array( 0, 0, 0, 40, 400, 500, 480, 600 ), $out );
    183183    }
Note: See TracChangeset for help on using the changeset viewer.