Make WordPress Core


Ignore:
Timestamp:
03/27/2014 08:39:08 PM (12 years ago)
Author:
wonderboymusic
Message:

In multi_resize() image editor methods, assert that null can only be passed for one of the arguments, not both. Add a lot more unit test assertions to ensure this.

Props pbearne, DH-Shredder.
Fixes #26823.

File:
1 edited

Legend:

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

    r25002 r27794  
    4040         */
    4141        protected function assertImageAlphaAtPoint( $image_path, $point, $alpha ) {
     42                $im = imagecreatefrompng( $image_path );
     43                $rgb = imagecolorat( $im, $point[0], $point[1] );
    4244
    43                 $im = imagecreatefrompng( $image_path );
    44                 $rgb = imagecolorat($im, $point[0], $point[1]);
    45 
    46                 $colors = imagecolorsforindex($im, $rgb);
     45                $colors = imagecolorsforindex( $im, $rgb );
    4746
    4847                $this->assertEquals( $alpha, $colors['alpha'] );
    4948        }
     49
     50        /**
     51         * Helper assertion to check actual image dimensions on disk
     52         *
     53         * @param string $filename Image filename.
     54         * @param int    $width    Width to verify.
     55         * @param int    $height   Height to verify.
     56         */
     57        protected function assertImageDimensions( $filename, $width, $height ) {
     58                $detected_width = 0;
     59                $detected_height = 0;
     60                $image_size = @getimagesize( $filename );
     61
     62                if ( isset( $image_size[0] ) ) {
     63                        $detected_width = $image_size[0];
     64                }
     65
     66                if ( isset( $image_size[1] ) ) {
     67                        $detected_height = $image_size[1];
     68                }
     69
     70                $this->assertEquals( $width, $detected_width );
     71                $this->assertEquals( $height, $detected_height );
     72        }
    5073}
Note: See TracChangeset for help on using the changeset viewer.