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

    r42228 r42343  
    2828
    2929    function test_resize_jpg() {
    30         $image = $this->resize_helper( DIR_TESTDATA.'/images/test-image.jpg', 25, 25 );
     30        $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 );
    3131
    3232        $this->assertEquals( 'test-image-25x25.jpg', basename( $image ) );
    33         list($w, $h, $type) = getimagesize($image);
     33        list($w, $h, $type) = getimagesize( $image );
    3434        $this->assertEquals( 25, $w );
    3535        $this->assertEquals( 25, $h );
     
    4040
    4141    function test_resize_png() {
    42         $image = $this->resize_helper( DIR_TESTDATA.'/images/test-image.png', 25, 25 );
     42        $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.png', 25, 25 );
    4343
    4444        if ( ! is_string( $image ) ) {  // WP_Error, stop GLib-GObject-CRITICAL assertion
     
    4747
    4848        $this->assertEquals( 'test-image-25x25.png', basename( $image ) );
    49         list($w, $h, $type) = getimagesize($image);
     49        list($w, $h, $type) = getimagesize( $image );
    5050        $this->assertEquals( 25, $w );
    5151        $this->assertEquals( 25, $h );
     
    5656
    5757    function test_resize_gif() {
    58         $image = $this->resize_helper( DIR_TESTDATA.'/images/test-image.gif', 25, 25 );
     58        $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.gif', 25, 25 );
    5959
    6060        if ( ! is_string( $image ) ) {  // WP_Error, stop GLib-GObject-CRITICAL assertion
     
    6363
    6464        $this->assertEquals( 'test-image-25x25.gif', basename( $image ) );
    65         list($w, $h, $type) = getimagesize($image);
     65        list($w, $h, $type) = getimagesize( $image );
    6666        $this->assertEquals( 25, $w );
    6767        $this->assertEquals( 25, $h );
     
    7373    function test_resize_larger() {
    7474        // image_resize() should refuse to make an image larger
    75         $image = $this->resize_helper( DIR_TESTDATA.'/images/test-image.jpg', 100, 100 );
     75        $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 100, 100 );
    7676
    7777        $this->assertInstanceOf( 'WP_Error', $image );
     
    8080
    8181    function test_resize_thumb_128x96() {
    82         $image = $this->resize_helper( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 128, 96 );
     82        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );
    8383
    8484        $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', basename( $image ) );
    85         list($w, $h, $type) = getimagesize($image);
     85        list($w, $h, $type) = getimagesize( $image );
    8686        $this->assertEquals( 64, $w );
    8787        $this->assertEquals( 96, $h );
     
    9292
    9393    function test_resize_thumb_128x0() {
    94         $image = $this->resize_helper( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 128, 0 );
     94        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 );
    9595
    9696        $this->assertEquals( '2007-06-17DSC_4173-128x193.jpg', basename( $image ) );
    97         list($w, $h, $type) = getimagesize($image);
     97        list($w, $h, $type) = getimagesize( $image );
    9898        $this->assertEquals( 128, $w );
    9999        $this->assertEquals( 193, $h );
     
    104104
    105105    function test_resize_thumb_0x96() {
    106         $image = $this->resize_helper( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 0, 96 );
     106        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 );
    107107
    108108        $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', basename( $image ) );
    109         list($w, $h, $type) = getimagesize($image);
     109        list($w, $h, $type) = getimagesize( $image );
    110110        $this->assertEquals( 64, $w );
    111111        $this->assertEquals( 96, $h );
     
    116116
    117117    function test_resize_thumb_150x150_crop() {
    118         $image = $this->resize_helper( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 150, 150, true );
     118        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true );
    119119
    120120        $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', basename( $image ) );
    121         list($w, $h, $type) = getimagesize($image);
     121        list($w, $h, $type) = getimagesize( $image );
    122122        $this->assertEquals( 150, $w );
    123123        $this->assertEquals( 150, $h );
     
    128128
    129129    function test_resize_thumb_150x100_crop() {
    130         $image = $this->resize_helper( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 150, 100, true );
     130        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true );
    131131
    132132        $this->assertEquals( '2007-06-17DSC_4173-150x100.jpg', basename( $image ) );
    133         list($w, $h, $type) = getimagesize($image);
     133        list($w, $h, $type) = getimagesize( $image );
    134134        $this->assertEquals( 150, $w );
    135135        $this->assertEquals( 100, $h );
     
    140140
    141141    function test_resize_thumb_50x150_crop() {
    142         $image = $this->resize_helper( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG', 50, 150, true );
     142        $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true );
    143143
    144144        $this->assertEquals( '2007-06-17DSC_4173-50x150.jpg', basename( $image ) );
    145         list($w, $h, $type) = getimagesize($image);
     145        list($w, $h, $type) = getimagesize( $image );
    146146        $this->assertEquals( 50, $w );
    147147        $this->assertEquals( 150, $h );
     
    153153    /**
    154154     * Try resizing a non-existent image
     155     *
    155156     * @ticket 6821
    156157     */
    157158    public function test_resize_non_existent_image() {
    158         $image = $this->resize_helper( DIR_TESTDATA.'/images/test-non-existent-image.jpg', 25, 25 );
     159        $image = $this->resize_helper( DIR_TESTDATA . '/images/test-non-existent-image.jpg', 25, 25 );
    159160
    160161        $this->assertInstanceOf( 'WP_Error', $image );
     
    168169        $editor = wp_get_image_editor( $file );
    169170
    170         if ( is_wp_error( $editor ) )
     171        if ( is_wp_error( $editor ) ) {
    171172            return $editor;
     173        }
    172174
    173175        $resized = $editor->resize( $width, $height, $crop );
    174         if ( is_wp_error( $resized ) )
     176        if ( is_wp_error( $resized ) ) {
    175177            return $resized;
     178        }
    176179
    177180        $dest_file = $editor->generate_filename();
    178         $saved = $editor->save( $dest_file );
     181        $saved     = $editor->save( $dest_file );
    179182
    180         if ( is_wp_error( $saved ) )
     183        if ( is_wp_error( $saved ) ) {
    181184            return $saved;
     185        }
    182186
    183187        return $dest_file;
Note: See TracChangeset for help on using the changeset viewer.