Make WordPress Core


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

    r41261 r42343  
    33/**
    44 * Test the WP_Image_Editor_Imagick class
     5 *
    56 * @group image
    67 * @group media
     
    7273                $imagick_image_editor->load();
    7374
    74                 $sizes_array =  array(
     75                $sizes_array = array(
    7576                        array(
    7677                                'width'  => 50,
     
    9495
    9596                // Now, verify real dimensions are as expected
    96                 $image_path = DIR_TESTDATA . '/images/'. $resized[0]['file'];
     97                $image_path = DIR_TESTDATA . '/images/' . $resized[0]['file'];
    9798                $this->assertImageDimensions(
    9899                        $image_path,
     
    143144                        ),
    144145                        array(
    145                                 'width'  => 0,
    146                         ),
    147                         array(
    148                                 'width'  => 0,
    149                                 'crop'   => true,
    150                         ),
    151                         array(
    152                                 'width'  => null,
    153                         ),
    154                         array(
    155                                 'width'  => null,
    156                                 'crop'   => true,
    157                         ),
    158                         array(
    159                                 'width'  => '',
    160                         ),
    161                         array(
    162                                 'width'  => '',
    163                                 'crop'   => true,
     146                                'width' => 0,
     147                        ),
     148                        array(
     149                                'width' => 0,
     150                                'crop'  => true,
     151                        ),
     152                        array(
     153                                'width' => null,
     154                        ),
     155                        array(
     156                                'width' => null,
     157                                'crop'  => true,
     158                        ),
     159                        array(
     160                                'width' => '',
     161                        ),
     162                        array(
     163                                'width' => '',
     164                                'crop'  => true,
    164165                        ),
    165166                );
     
    365366                $this->assertEquals( $expected_array, $resized );
    366367
    367                 foreach( $resized as $key => $image_data ){
     368                foreach ( $resized as $key => $image_data ) {
    368369                        $image_path = DIR_TESTDATA . '/images/' . $image_data['file'];
    369370
     
    371372                        $this->assertImageDimensions(
    372373                                $image_path,
    373                                 $expected_array[$key]['width'],
    374                                 $expected_array[$key]['height']
     374                                $expected_array[ $key ]['width'],
     375                                $expected_array[ $key ]['height']
    375376                        );
    376377                }
     
    410411                $this->assertEquals(
    411412                        array(
    412                                 'width' => 50,
     413                                'width'  => 50,
    413414                                'height' => 50,
    414415                        ),
     
    466467
    467468                $this->assertNotInstanceOf( 'WP_Error', $editor );
    468                
     469
    469470                $editor->load();
    470471                $editor->resize( 5, 5 );
     
    473474                $editor->save( $save_to_file );
    474475
    475                 $im = new Imagick( $save_to_file );
    476                 $pixel = $im->getImagePixelColor( 0, 0 );
     476                $im       = new Imagick( $save_to_file );
     477                $pixel    = $im->getImagePixelColor( 0, 0 );
    477478                $expected = $pixel->getColorValue( imagick::COLOR_ALPHA );
    478479
    479                 $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0,0 ), $expected );
     480                $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0, 0 ), $expected );
    480481
    481482                unlink( $save_to_file );
     
    500501                $editor->save( $save_to_file );
    501502
    502                 $im = new Imagick( $save_to_file );
    503                 $pixel = $im->getImagePixelColor( 0, 0 );
     503                $im       = new Imagick( $save_to_file );
     504                $pixel    = $im->getImagePixelColor( 0, 0 );
    504505                $expected = $pixel->getColorValue( imagick::COLOR_ALPHA );
    505506
    506                 $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0,0 ), $expected );
     507                $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0, 0 ), $expected );
    507508
    508509                unlink( $save_to_file );
     
    510511
    511512        /**
    512          *
    513513         * @ticket 30596
    514514         */
     
    517517
    518518                $pre_rotate_editor = new Imagick( $file );
    519                 $pre_rotate_pixel = $pre_rotate_editor->getImagePixelColor( 0, 0 );
    520                 $pre_rotate_alpha = $pre_rotate_pixel->getColorValue( imagick::COLOR_ALPHA );
    521                 $save_to_file = tempnam( get_temp_dir(),'' ) . '.png';
     519                $pre_rotate_pixel  = $pre_rotate_editor->getImagePixelColor( 0, 0 );
     520                $pre_rotate_alpha  = $pre_rotate_pixel->getColorValue( imagick::COLOR_ALPHA );
     521                $save_to_file      = tempnam( get_temp_dir(), '' ) . '.png';
    522522                $pre_rotate_editor->writeImage( $save_to_file );
    523523                $pre_rotate_editor->destroy();
     
    535535        /**
    536536         * Test WP_Image_Editor_Imagick handles extension-less images
     537         *
    537538         * @ticket 39195
    538539         */
    539540        public function test_image_non_existent_extension() {
    540                 $image_editor = new WP_Image_Editor_Imagick( DIR_TESTDATA.'/images/test-image-no-extension' );
    541                 $result = $image_editor->load();
     541                $image_editor = new WP_Image_Editor_Imagick( DIR_TESTDATA . '/images/test-image-no-extension' );
     542                $result       = $image_editor->load();
    542543
    543544                $this->assertTrue( $result );
     
    550551         */
    551552        public function test_remove_orientation_data_on_rotate() {
    552                 $file = DIR_TESTDATA . "/images/test-image-upside-down.jpg";
     553                $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg';
    553554                $data = wp_read_image_metadata( $file );
    554555
     
    557558
    558559                $temp_file = wp_tempnam( $file );
    559                 $image = wp_get_image_editor( $file );
     560                $image     = wp_get_image_editor( $file );
    560561
    561562                // Test a value that would not lead back to 1, as WP is resetting the value to 1 manually.
Note: See TracChangeset for help on using the changeset viewer.