Changeset 50251 for branches/3.7/tests
- Timestamp:
- 02/08/2021 08:58:53 PM (5 years ago)
- Location:
- branches/3.7
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
tests/phpunit/tests/image/base.php (modified) (3 diffs)
-
tests/phpunit/tests/image/editor_gd.php (modified) (6 diffs)
-
tests/phpunit/tests/image/editor_imagick.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.7
- Property svn:mergeinfo changed
/branches/5.0 merged: 43836 /trunk merged: 44176,45445,45745,45762,45783-45784,45800,45819,45885,46320,46999,47225,47912,48121,49267,49335,49358,49360,49362
- Property svn:mergeinfo changed
-
branches/3.7/tests/phpunit/tests/image/base.php
r47343 r50251 38 38 39 39 /** 40 * Helper assertion for testing alpha on images 40 * Helper assertion for testing alpha on images using GD library 41 41 * 42 42 * @param string $image_path … … 44 44 * @param int $alpha 45 45 */ 46 protected function assertImageAlphaAtPoint ( $image_path, $point, $alpha ) {46 protected function assertImageAlphaAtPointGD( $image_path, $point, $alpha ) { 47 47 48 48 $im = imagecreatefrompng( $image_path ); … … 53 53 $this->assertEquals( $alpha, $colors['alpha'] ); 54 54 } 55 56 /** 57 * Helper assertion for testing alpha on images using Imagick 58 * 59 * @param string $image_path 60 * @param array $point array(x,y) 61 * @param int $expected 62 */ 63 protected function assertImageAlphaAtPointImagick( $image_path, $point, $expected ) { 64 $im = new Imagick( $image_path ); 65 $pixel = $im->getImagePixelColor( $point[0], $point[1] ); 66 $color = $pixel->getColorValue( imagick::COLOR_ALPHA ); 67 $this->assertEquals( $expected, $color ); 68 } 55 69 } -
branches/3.7/tests/phpunit/tests/image/editor_gd.php
r47343 r50251 33 33 /** 34 34 * Check support for GD compatible mime types. 35 * 35 * 36 36 */ 37 37 public function test_supports_mime_type() { … … 45 45 /** 46 46 * Test resizing an image, not using crop 47 * 47 * 48 48 */ 49 49 public function test_resize() { … … 61 61 /** 62 62 * Test resizing an image including cropping 63 * 63 * 64 64 */ 65 65 public function test_resize_and_crop() { … … 133 133 /** 134 134 * Test the image created with WP_Image_Edior_GD preserves alpha when resizing 135 * 135 * 136 136 * @ticket 23039 137 137 */ … … 144 144 $editor->resize(5,5); 145 145 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; 146 146 147 147 $editor->save( $save_to_file ); 148 148 149 $this->assertImageAlphaAtPoint ( $save_to_file, array( 0,0 ), 127 );149 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0,0 ), 127 ); 150 150 151 151 unlink( $save_to_file ); 152 152 } 153 153 154 154 /** 155 155 * Test the image created with WP_Image_Edior_GD preserves alpha with no resizing etc 156 * 156 * 157 157 * @ticket 23039 158 158 */ … … 165 165 166 166 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; 167 167 168 168 $editor->save( $save_to_file ); 169 169 170 $this->assertImageAlphaAtPoint ( $save_to_file, array( 0,0 ), 127 );170 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0,0 ), 127 ); 171 171 172 172 unlink( $save_to_file ); -
branches/3.7/tests/phpunit/tests/image/editor_imagick.php
r47343 r50251 39 39 /** 40 40 * Check support for Image Magick compatible mime types. 41 * 41 * 42 42 */ 43 43 public function test_supports_mime_type() { … … 52 52 /** 53 53 * Test resizing an image, not using crop 54 * 54 * 55 55 */ 56 56 public function test_resize() { … … 68 68 /** 69 69 * Test resizing an image including cropping 70 * 70 * 71 71 */ 72 72 public function test_resize_and_crop() { … … 151 151 $editor->resize(5,5); 152 152 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; 153 153 154 154 $editor->save( $save_to_file ); 155 155 156 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 ); 156 $im = new Imagick( $save_to_file ); 157 $pixel = $im->getImagePixelColor( 0, 0 ); 158 $expected = $pixel->getColorValue( imagick::COLOR_ALPHA ); 159 160 $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0,0 ), $expected ); 157 161 158 162 unlink( $save_to_file ); 159 163 } 160 164 161 165 /** 162 166 * Test the image created with WP_Image_Edior_Imagick preserves alpha with no resizing etc … … 175 179 $editor->save( $save_to_file ); 176 180 177 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 ); 181 $im = new Imagick( $save_to_file ); 182 $pixel = $im->getImagePixelColor( 0, 0 ); 183 $expected = $pixel->getColorValue( imagick::COLOR_ALPHA ); 184 185 $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0,0 ), $expected ); 178 186 179 187 unlink( $save_to_file );
Note: See TracChangeset
for help on using the changeset viewer.