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/intermediateSize.php

    r41261 r42343  
    1818    public function _make_attachment( $file, $parent_post_id = 0 ) {
    1919        $contents = file_get_contents( $file );
    20         $upload = wp_upload_bits( basename( $file ), null, $contents );
     20        $upload   = wp_upload_bits( basename( $file ), null, $contents );
    2121
    2222        return parent::_make_attachment( $upload, $parent_post_id );
     
    3030
    3131    function test_make_intermediate_size_width() {
    32         if ( !function_exists( 'imagejpeg' ) )
     32        if ( ! function_exists( 'imagejpeg' ) ) {
    3333            $this->fail( 'jpeg support unavailable' );
     34        }
    3435
    3536        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false );
     
    3940
    4041    function test_make_intermediate_size_height() {
    41         if ( !function_exists( 'imagejpeg' ) )
     42        if ( ! function_exists( 'imagejpeg' ) ) {
    4243            $this->fail( 'jpeg support unavailable' );
     44        }
    4345
    4446        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false );
     
    4850
    4951    function test_make_intermediate_size_successful() {
    50         if ( !function_exists( 'imagejpeg' ) )
     52        if ( ! function_exists( 'imagejpeg' ) ) {
    5153            $this->fail( 'jpeg support unavailable' );
     54        }
    5255
    5356        $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true );
     
    6467
    6568    /**
    66     * @ticket 17626
    67     */
     69     * @ticket 17626
     70     */
    6871    function test_get_intermediate_sizes_by_name() {
    6972        add_image_size( 'test-size', 330, 220, true );
    7073
    7174        $file = DIR_TESTDATA . '/images/waffles.jpg';
    72         $id = $this->_make_attachment( $file, 0 );
     75        $id   = $this->_make_attachment( $file, 0 );
    7376
    7477        // look for a size by name
     
    8487
    8588    /**
    86     * @ticket 17626
    87     */
     89     * @ticket 17626
     90     */
    8891    function test_get_intermediate_sizes_by_array_exact() {
    8992        // Only one dimention match shouldn't return false positive (see: 17626)
     
    9396
    9497        $file = DIR_TESTDATA . '/images/waffles.jpg';
    95         $id = $this->_make_attachment( $file, 0 );
     98        $id   = $this->_make_attachment( $file, 0 );
    9699
    97100        // look for a size by array that exists
     
    105108
    106109    /**
    107     * @ticket 17626
    108     */
     110     * @ticket 17626
     111     */
    109112    function test_get_intermediate_sizes_by_array_nearest() {
    110113        // If an exact size is not found, it should be returned
     
    115118
    116119        $file = DIR_TESTDATA . '/images/waffles.jpg';
    117         $id = $this->_make_attachment( $file, 0 );
     120        $id   = $this->_make_attachment( $file, 0 );
    118121
    119122        // look for a size by array that doesn't exist
     
    127130
    128131    /**
    129     * @ticket 17626
    130     */
     132     * @ticket 17626
     133     */
    131134    function test_get_intermediate_sizes_by_array_nearest_false() {
    132135        // If an exact size is not found, it should be returned
     
    136139
    137140        $file = DIR_TESTDATA . '/images/waffles.jpg';
    138         $id = $this->_make_attachment( $file, 0 );
     141        $id   = $this->_make_attachment( $file, 0 );
    139142
    140143        // look for a size by array that doesn't exist
     
    148151
    149152    /**
    150     * @ticket 17626
    151     */
     153     * @ticket 17626
     154     */
    152155    function test_get_intermediate_sizes_by_array_zero_height() {
    153156        // Generate random width
     
    159162
    160163        $file = DIR_TESTDATA . '/images/waffles.jpg';
    161         $id = $this->_make_attachment( $file, 0 );
     164        $id   = $this->_make_attachment( $file, 0 );
    162165
    163166        $original = wp_get_attachment_metadata( $id );
    164         $image_w = $random_w;
    165         $image_h = round( ( $image_w / $original['width'] ) * $original['height'] );
     167        $image_w  = $random_w;
     168        $image_h  = round( ( $image_w / $original['width'] ) * $original['height'] );
    166169
    167170        // look for a size by array that exists
     
    187190
    188191        $file = DIR_TESTDATA . '/images/waffles.jpg';
    189         $id = $this->_make_attachment( $file, 0 );
     192        $id   = $this->_make_attachment( $file, 0 );
    190193
    191194        $original = wp_get_attachment_metadata( $id );
    192         $image_h = $height;
    193         $image_w = round( ( $image_h / $original['height'] ) * $original['width'] );
     195        $image_h  = $height;
     196        $image_w  = round( ( $image_h / $original['height'] ) * $original['width'] );
    194197
    195198        // look for a size by array that exists
     
    213216
    214217        $file = DIR_TESTDATA . '/images/waffles.jpg';
    215         $id = $this->_make_attachment( $file, 0 );
     218        $id   = $this->_make_attachment( $file, 0 );
    216219
    217220        $original = wp_get_attachment_metadata( $id );
    218         $image_h = $height;
    219         $image_w = round( ( $image_h / $original['height'] ) * $original['width'] );
     221        $image_h  = $height;
     222        $image_w  = round( ( $image_h / $original['height'] ) * $original['width'] );
    220223
    221224        // look for a size by array that exists
     
    234237
    235238        $file = DIR_TESTDATA . '/images/waffles.jpg';
    236         $id = $this->_make_attachment( $file, 0 );
     239        $id   = $this->_make_attachment( $file, 0 );
    237240
    238241        // Request a size by array that doesn't exist and is smaller than the 'thumbnail'
     
    248251    public function test_get_intermediate_size_with_small_size_array_fallback() {
    249252        $file = DIR_TESTDATA . '/images/waffles.jpg';
    250         $id = $this->_make_attachment( $file, 0 );
    251 
    252         $original = wp_get_attachment_metadata( $id );
     253        $id   = $this->_make_attachment( $file, 0 );
     254
     255        $original       = wp_get_attachment_metadata( $id );
    253256        $thumbnail_file = $original['sizes']['thumbnail']['file'];
    254257
Note: See TracChangeset for help on using the changeset viewer.