<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27794] trunk: In `multi_resize()` image editor methods, assert that `null` can only be passed for one of the arguments, not both.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27794">27794</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-03-27 20:39:08 +0000 (Thu, 27 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/26823">#26823</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpimageeditorgdphp">trunk/src/wp-includes/class-wp-image-editor-gd.php</a></li>
<li><a href="#trunksrcwpincludesclasswpimageeditorimagickphp">trunk/src/wp-includes/class-wp-image-editor-imagick.php</a></li>
<li><a href="#trunksrcwpincludesclasswpimageeditorphp">trunk/src/wp-includes/class-wp-image-editor.php</a></li>
<li><a href="#trunktestsphpunittestsimagebasephp">trunk/tests/phpunit/tests/image/base.php</a></li>
<li><a href="#trunktestsphpunittestsimageeditor_gdphp">trunk/tests/phpunit/tests/image/editor_gd.php</a></li>
<li><a href="#trunktestsphpunittestsimageeditor_imagickphp">trunk/tests/phpunit/tests/image/editor_imagick.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpimageeditorgdphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/class-wp-image-editor-gd.php (27793 => 27794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/class-wp-image-editor-gd.php       2014-03-27 20:26:24 UTC (rev 27793)
+++ trunk/src/wp-includes/class-wp-image-editor-gd.php  2014-03-27 20:39:08 UTC (rev 27794)
</span><span class="lines">@@ -140,12 +140,16 @@
</span><span class="cx">   * Resizes current image.
</span><span class="cx">   * Wraps _resize, since _resize returns a GD Resource.
</span><span class="cx">   *
</span><ins>+        * At minimum, either a height or width must be provided.
+        * If one of the two is set to null, the resize will
+        * maintain aspect ratio according to the provided dimension.
+        *
</ins><span class="cx">    * @since 3.5.0
</span><span class="cx">   * @access public
</span><span class="cx">   *
</span><del>-        * @param int $max_w
-        * @param int $max_h
-        * @param boolean $crop
</del><ins>+         * @param  int|null $max_w Image width.
+        * @param  int|null $max_h Image height.
+        * @param  boolean  $crop
</ins><span class="cx">    * @return boolean|WP_Error
</span><span class="cx">   */
</span><span class="cx">  public function resize( $max_w, $max_h, $crop = false ) {
</span><span class="lines">@@ -192,24 +196,37 @@
</span><span class="cx">   * @param array $sizes {
</span><span class="cx">   *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
</span><span class="cx">   *
</span><ins>+        *     Either a height or width must be provided.
+        *     If one of the two is set to null, the resize will
+        *     maintain aspect ratio according to the provided dimension.
+        *
</ins><span class="cx">    *     @type array $size {
</span><del>-        *         @type int  $width  Image width.
-        *         @type int  $height Image height.
-        *         @type bool $crop   Optional. Whether to crop the image. Default false.
</del><ins>+         *         @type int  ['width']  Optional. Image width.
+        *         @type int  ['height'] Optional. Image height.
+        *         @type bool ['crop']   Optional. Whether to crop the image. Default false.
</ins><span class="cx">    *     }
</span><span class="cx">   * }
</span><del>-        * @return array An array of resized images metadata by size.
</del><ins>+         * @return array An array of resized images' metadata by size.
</ins><span class="cx">    */
</span><span class="cx">  public function multi_resize( $sizes ) {
</span><span class="cx">          $metadata = array();
</span><span class="cx">          $orig_size = $this->size;
</span><span class="cx"> 
</span><span class="cx">          foreach ( $sizes as $size => $size_data ) {
</span><del>-                       if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
</del><ins>+                        if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
</ins><span class="cx">                           continue;
</span><ins>+                       }
</ins><span class="cx"> 
</span><del>-                       if ( ! isset( $size_data['crop'] ) )
</del><ins>+                        if ( ! isset( $size_data['width'] ) ) {
+                               $size_data['width'] = null;
+                       }
+                       if ( ! isset( $size_data['height'] ) ) {
+                               $size_data['height'] = null;
+                       }
+
+                       if ( ! isset( $size_data['crop'] ) ) {
</ins><span class="cx">                           $size_data['crop'] = false;
</span><ins>+                       }
</ins><span class="cx"> 
</span><span class="cx">                  $image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpimageeditorimagickphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/class-wp-image-editor-imagick.php (27793 => 27794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/class-wp-image-editor-imagick.php  2014-03-27 20:26:24 UTC (rev 27793)
+++ trunk/src/wp-includes/class-wp-image-editor-imagick.php     2014-03-27 20:39:08 UTC (rev 27794)
</span><span class="lines">@@ -211,12 +211,16 @@
</span><span class="cx">  /**
</span><span class="cx">   * Resizes current image.
</span><span class="cx">   *
</span><ins>+        * At minimum, either a height or width must be provided.
+        * If one of the two is set to null, the resize will
+        * maintain aspect ratio according to the provided dimension.
+        *
</ins><span class="cx">    * @since 3.5.0
</span><span class="cx">   * @access public
</span><span class="cx">   *
</span><del>-        * @param int $max_w
-        * @param int $max_h
-        * @param boolean $crop
</del><ins>+         * @param  int|null $max_w Image width.
+        * @param  int|null $max_h Image height.
+        * @param  boolean  $crop
</ins><span class="cx">    * @return boolean|WP_Error
</span><span class="cx">   */
</span><span class="cx">  public function resize( $max_w, $max_h, $crop = false ) {
</span><span class="lines">@@ -255,13 +259,17 @@
</span><span class="cx">   * @param array $sizes {
</span><span class="cx">   *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
</span><span class="cx">   *
</span><ins>+        *     Either a height or width must be provided.
+        *     If one of the two is set to null, the resize will
+        *     maintain aspect ratio according to the provided dimension.
+        *
</ins><span class="cx">    *     @type array $size {
</span><del>-        *         @type int  $width  Image width.
-        *         @type int  $height Image height.
</del><ins>+         *         @type int  ['width']  Optional. Image width.
+        *         @type int  ['height'] Optional. Image height.
</ins><span class="cx">    *         @type bool $crop   Optional. Whether to crop the image. Default false.
</span><span class="cx">   *     }
</span><span class="cx">   * }
</span><del>-        * @return array An array of resized images metadata by size.
</del><ins>+         * @return array An array of resized images' metadata by size.
</ins><span class="cx">    */
</span><span class="cx">  public function multi_resize( $sizes ) {
</span><span class="cx">          $metadata = array();
</span><span class="lines">@@ -272,11 +280,20 @@
</span><span class="cx">                  if ( ! $this->image )
</span><span class="cx">                          $this->image = $orig_image->getImage();
</span><span class="cx"> 
</span><del>-                       if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
</del><ins>+                        if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
</ins><span class="cx">                           continue;
</span><ins>+                       }
</ins><span class="cx"> 
</span><del>-                       if ( ! isset( $size_data['crop'] ) )
</del><ins>+                        if ( ! isset( $size_data['width'] ) ) {
+                               $size_data['width'] = null;
+                       }
+                       if ( ! isset( $size_data['height'] ) ) {
+                               $size_data['height'] = null;
+                       }
+
+                       if ( ! isset( $size_data['crop'] ) ) {
</ins><span class="cx">                           $size_data['crop'] = false;
</span><ins>+                       }
</ins><span class="cx"> 
</span><span class="cx">                  $resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpimageeditorphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/class-wp-image-editor.php (27793 => 27794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/class-wp-image-editor.php  2014-03-27 20:26:24 UTC (rev 27793)
+++ trunk/src/wp-includes/class-wp-image-editor.php     2014-03-27 20:39:08 UTC (rev 27794)
</span><span class="lines">@@ -82,13 +82,17 @@
</span><span class="cx">  /**
</span><span class="cx">   * Resizes current image.
</span><span class="cx">   *
</span><ins>+        * At minimum, either a height or width must be provided.
+        * If one of the two is set to null, the resize will
+        * maintain aspect ratio according to the provided dimension.
+        *
</ins><span class="cx">    * @since 3.5.0
</span><span class="cx">   * @access public
</span><span class="cx">   * @abstract
</span><span class="cx">   *
</span><del>-        * @param int $max_w
-        * @param int $max_h
-        * @param boolean $crop
</del><ins>+         * @param  int|null $max_w Image width.
+        * @param  int|null $max_h Image height.
+        * @param  boolean  $crop
</ins><span class="cx">    * @return boolean|WP_Error
</span><span class="cx">   */
</span><span class="cx">  abstract public function resize( $max_w, $max_h, $crop = false );
</span></span></pre></div>
<a id="trunktestsphpunittestsimagebasephp"></a>
<div class="modfile"><h4>Modified: trunk/tests/phpunit/tests/image/base.php (27793 => 27794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/phpunit/tests/image/base.php 2014-03-27 20:26:24 UTC (rev 27793)
+++ trunk/tests/phpunit/tests/image/base.php    2014-03-27 20:39:08 UTC (rev 27794)
</span><span class="lines">@@ -39,12 +39,35 @@
</span><span class="cx">   * @param  int $alpha
</span><span class="cx">   */
</span><span class="cx">  protected function assertImageAlphaAtPoint( $image_path, $point, $alpha ) {
</span><del>-
</del><span class="cx">           $im = imagecreatefrompng( $image_path );
</span><del>-               $rgb = imagecolorat($im, $point[0], $point[1]);
</del><ins>+                $rgb = imagecolorat( $im, $point[0], $point[1] );
</ins><span class="cx"> 
</span><del>-               $colors = imagecolorsforindex($im, $rgb);
</del><ins>+                $colors = imagecolorsforindex( $im, $rgb );
</ins><span class="cx"> 
</span><span class="cx">          $this->assertEquals( $alpha, $colors['alpha'] );
</span><span class="cx">  }
</span><ins>+
+       /**
+        * Helper assertion to check actual image dimensions on disk
+        *
+        * @param string $filename Image filename.
+        * @param int    $width    Width to verify.
+        * @param int    $height   Height to verify.
+        */
+       protected function assertImageDimensions( $filename, $width, $height ) {
+               $detected_width = 0;
+               $detected_height = 0;
+               $image_size = @getimagesize( $filename );
+
+               if ( isset( $image_size[0] ) ) {
+                       $detected_width = $image_size[0];
+               }
+
+               if ( isset( $image_size[1] ) ) {
+                       $detected_height = $image_size[1];
+               }
+
+               $this->assertEquals( $width, $detected_width );
+               $this->assertEquals( $height, $detected_height );
+       }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsimageeditor_gdphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/phpunit/tests/image/editor_gd.php (27793 => 27794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/phpunit/tests/image/editor_gd.php    2014-03-27 20:26:24 UTC (rev 27793)
+++ trunk/tests/phpunit/tests/image/editor_gd.php       2014-03-27 20:39:08 UTC (rev 27794)
</span><span class="lines">@@ -8,17 +8,28 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
</span><ins>+
</ins><span class="cx">   public $editor_engine = 'WP_Image_Editor_GD';
</span><span class="cx"> 
</span><del>-       public function setup() {
</del><ins>+        public function setUp() {
</ins><span class="cx">           require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' );
</span><span class="cx">          require_once( ABSPATH . WPINC . '/class-wp-image-editor-gd.php' );
</span><ins>+
</ins><span class="cx">           parent::setUp();
</span><span class="cx">  }
</span><span class="cx"> 
</span><ins>+       public function shutDown() {
+               $folder = DIR_TESTDATA . '/images/waffles-*.jpg';
+
+               foreach ( glob( $folder ) as $file ) {
+                       unlink( $file );
+               }
+
+               parent::shutDown();
+       }
+
</ins><span class="cx">   /**
</span><span class="cx">   * Check support for GD compatible mime types.
</span><del>-        * 
</del><span class="cx">    */
</span><span class="cx">  public function test_supports_mime_type() {
</span><span class="cx">          $gd_image_editor = new WP_Image_Editor_GD( null );
</span><span class="lines">@@ -30,41 +41,362 @@
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Test resizing an image, not using crop
</span><del>-        * 
</del><span class="cx">    */
</span><span class="cx">  public function test_resize() {
</span><ins>+               $file = DIR_TESTDATA . '/images/waffles.jpg';
</ins><span class="cx"> 
</span><del>-               $file = DIR_TESTDATA . '/images/gradient-square.jpg';
-
</del><span class="cx">           $gd_image_editor = new WP_Image_Editor_GD( $file );
</span><span class="cx">          $gd_image_editor->load();
</span><span class="cx"> 
</span><span class="cx">          $gd_image_editor->resize( 100, 50 );
</span><span class="cx"> 
</span><del>-               $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $gd_image_editor->get_size() );
</del><ins>+                $this->assertEquals(
+                       array(
+                               'width'  => 75,
+                               'height' => 50,
+                       ),
+                       $gd_image_editor->get_size()
+               );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Test resizing an image including cropping
-        * 
</del><ins>+         * Test multi_resize with single image resize and no crop
</ins><span class="cx">    */
</span><del>-       public function test_resize_and_crop() {
</del><ins>+        public function test_single_multi_resize() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
</ins><span class="cx"> 
</span><del>-               $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</del><ins>+                $gd_image_editor = new WP_Image_Editor_GD( $file );
+               $gd_image_editor->load();
</ins><span class="cx"> 
</span><ins>+               $sizes_array =  array(
+                       array(
+                               'width'  => 50,
+                               'height' => 50,
+                       ),
+               );
+
+               $resized = $gd_image_editor->multi_resize( $sizes_array );
+
+               # First, check to see if returned array is as expected
+               $expected_array = array(
+                       array(
+                               'file'      => 'waffles-50x33.jpg',
+                               'width'     => 50,
+                               'height'    => 33,
+                               'mime-type' => 'image/jpeg',
+                       ),
+               );
+
+               $this->assertEquals( $expected_array, $resized );
+
+               // Now, verify real dimensions are as expected
+               $image_path = DIR_TESTDATA . '/images/'. $resized[0]['file'];
+               $this->assertImageDimensions(
+                       $image_path,
+                       $expected_array[0]['width'],
+                       $expected_array[0]['height']
+               );
+       }
+
+       /**
+        * Ensure multi_resize doesn't create an image when
+        * both height and weight are missing, null, or 0.
+        *
+        * ticket 26823
+        */
+       public function test_multi_resize_does_not_create() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
+
</ins><span class="cx">           $gd_image_editor = new WP_Image_Editor_GD( $file );
</span><span class="cx">          $gd_image_editor->load();
</span><span class="cx"> 
</span><ins>+               $sizes_array = array(
+                       array(
+                               'width'  => 0,
+                               'height' => 0,
+                       ),
+                       array(
+                               'width'  => 0,
+                               'height' => 0,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => null,
+                               'height' => null,
+                       ),
+                       array(
+                               'width'  => null,
+                               'height' => null,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => '',
+                               'height' => '',
+                       ),
+                       array(
+                               'width'  => '',
+                               'height' => '',
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => 0,
+                       ),
+                       array(
+                               'width'  => 0,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => null,
+                       ),
+                       array(
+                               'width'  => null,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => '',
+                       ),
+                       array(
+                               'width'  => '',
+                               'crop'   => true,
+                       ),
+               );
+
+               $resized = $gd_image_editor->multi_resize( $sizes_array );
+
+               // If no images are generated, the returned array is empty.
+               $this->assertEmpty( $resized );
+       }
+
+       /**
+        * Test multi_resize with multiple sizes
+        *
+        * ticket 26823
+        */
+       public function test_multi_resize() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
+
+               $gd_image_editor = new WP_Image_Editor_GD( $file );
+               $gd_image_editor->load();
+
+               $sizes_array = array(
+
+                       /**
+                        * #0 - 10x10 resize, no cropping.
+                        * By aspect, should be 10x6 output.
+                        */
+                       array(
+                               'width'  => 10,
+                               'height' => 10,
+                               'crop'   => false,
+                       ),
+
+                       /**
+                        * #1 - 75x50 resize, with cropping.
+                        * Output dimensions should be 75x50
+                        */
+                       array(
+                               'width'  => 75,
+                               'height' => 50,
+                               'crop'   => true,
+                       ),
+
+                       /**
+                        * #2 - 20 pixel max height, no cropping.
+                        * By aspect, should be 30x20 output.
+                        */
+                       array(
+                               'width'  => 9999, # Arbitrary High Value
+                               'height' => 20,
+                               'crop'   => false,
+                       ),
+
+                       /**
+                        * #3 - 45 pixel max height, with cropping.
+                        * By aspect, should be 45x400 output.
+                        */
+                       array(
+                               'width'  => 45,
+                               'height' => 9999, # Arbitrary High Value
+                               'crop'   => true,
+                       ),
+
+                       /**
+                        * #4 - 50 pixel max width, no cropping.
+                        * By aspect, should be 50x33 output.
+                        */
+                       array(
+                               'width' => 50,
+                       ),
+
+                       /**
+                        * #5 - 55 pixel max width, no cropping, null height
+                        * By aspect, should be 55x36 output.
+                        */
+                       array(
+                               'width'  => 55,
+                               'height' => null,
+                       ),
+
+                       /**
+                        * #6 - 55 pixel max height, no cropping, no width specified.
+                        * By aspect, should be 82x55 output.
+                        */
+                       array(
+                               'height' => 55,
+                       ),
+
+                       /**
+                        * #7 - 60 pixel max height, no cropping, null width.
+                        * By aspect, should be 90x60 output.
+                        */
+                       array(
+                               'width'  => null,
+                               'height' => 60,
+                       ),
+
+                       /**
+                        * #8 - 70 pixel max height, no cropping, negative width.
+                        * By aspect, should be 105x70 output.
+                        */
+                       array(
+                               'width'  => -9999, # Arbitrary Negative Value
+                               'height' => 70,
+                       ),
+
+                       /**
+                        * #9 - 200 pixel max width, no cropping, negative height.
+                        * By aspect, should be 200x133 output.
+                        */
+                       array(
+                               'width'  => 200,
+                               'height' => -9999, # Arbitrary Negative Value
+                       ),
+               );
+
+               $resized = $gd_image_editor->multi_resize( $sizes_array );
+
+               $expected_array = array(
+
+                       // #0
+                       array(
+                               'file'      => 'waffles-10x6.jpg',
+                               'width'     => 10,
+                               'height'    => 6,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #1
+                       array(
+                               'file'      => 'waffles-75x50.jpg',
+                               'width'     => 75,
+                               'height'    => 50,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #2
+                       array(
+                               'file'      => 'waffles-30x20.jpg',
+                               'width'     => 30,
+                               'height'    => 20,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #3
+                       array(
+                               'file'      => 'waffles-45x400.jpg',
+                               'width'     => 45,
+                               'height'    => 400,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #4
+                       array(
+                               'file'      => 'waffles-50x33.jpg',
+                               'width'     => 50,
+                               'height'    => 33,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #5
+                       array(
+                               'file'      => 'waffles-55x36.jpg',
+                               'width'     => 55,
+                               'height'    => 36,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #6
+                       array(
+                               'file'      => 'waffles-82x55.jpg',
+                               'width'     => 82,
+                               'height'    => 55,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #7
+                       array(
+                               'file'      => 'waffles-90x60.jpg',
+                               'width'     => 90,
+                               'height'    => 60,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #8
+                       array(
+                               'file'      => 'waffles-105x70.jpg',
+                               'width'     => 105,
+                               'height'    => 70,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #9
+                       array(
+                               'file'      => 'waffles-200x133.jpg',
+                               'width'     => 200,
+                               'height'    => 133,
+                               'mime-type' => 'image/jpeg',
+                       ),
+               );
+
+               $this->assertNotNull( $resized );
+               $this->assertEquals( $expected_array, $resized );
+
+               foreach( $resized as $key => $image_data ){
+                       $image_path = DIR_TESTDATA . '/images/' . $image_data['file'];
+
+                       // Now, verify real dimensions are as expected
+                       $this->assertImageDimensions(
+                               $image_path,
+                               $expected_array[$key]['width'],
+                               $expected_array[$key]['height']
+                       );
+               }
+       }
+
+       /**
+        * Test resizing an image with cropping
+        */
+       public function test_resize_and_crop() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
+
+               $gd_image_editor = new WP_Image_Editor_GD( $file );
+               $gd_image_editor->load();
+
</ins><span class="cx">           $gd_image_editor->resize( 100, 50, true );
</span><span class="cx"> 
</span><del>-               $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $gd_image_editor->get_size() );
</del><ins>+                $this->assertEquals(
+                       array(
+                               'width'  => 100,
+                               'height' => 50,
+                       ),
+                       $gd_image_editor->get_size()
+               );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Test cropping an image
</span><span class="cx">   */
</span><span class="cx">  public function test_crop() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</span><span class="cx"> 
</span><span class="cx">          $gd_image_editor = new WP_Image_Editor_GD( $file );
</span><span class="lines">@@ -72,15 +404,19 @@
</span><span class="cx"> 
</span><span class="cx">          $gd_image_editor->crop( 0, 0, 50, 50 );
</span><span class="cx"> 
</span><del>-               $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $gd_image_editor->get_size() );
-
</del><ins>+                $this->assertEquals(
+                       array(
+                               'width' => 50,
+                               'height' => 50,
+                       ),
+                       $gd_image_editor->get_size()
+               );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Test rotating an image 180 deg
</span><span class="cx">   */
</span><span class="cx">  public function test_rotate() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</span><span class="cx"> 
</span><span class="cx">          $gd_image_editor = new WP_Image_Editor_GD( $file );
</span><span class="lines">@@ -100,7 +436,6 @@
</span><span class="cx">   * Test flipping an image
</span><span class="cx">   */
</span><span class="cx">  public function test_flip() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</span><span class="cx"> 
</span><span class="cx">          $gd_image_editor = new WP_Image_Editor_GD( $file );
</span><span class="lines">@@ -117,42 +452,38 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Test the image created with WP_Image_Edior_GD preserves alpha when resizing
-        * 
</del><ins>+         * Test the image created with WP_Image_Editor_GD preserves alpha when resizing
+        *
</ins><span class="cx">    * @ticket 23039
</span><span class="cx">   */
</span><span class="cx">  public function test_image_preserves_alpha_on_resize() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/transparent.png';
</span><span class="cx"> 
</span><span class="cx">          $editor = wp_get_image_editor( $file );
</span><span class="cx">          $editor->load();
</span><del>-               $editor->resize(5,5);
</del><ins>+                $editor->resize( 5, 5 );
</ins><span class="cx">           $save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
</span><del>-               
</del><ins>+
</ins><span class="cx">           $editor->save( $save_to_file );
</span><span class="cx"> 
</span><span class="cx">          $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 );
</span><ins>+       }
</ins><span class="cx"> 
</span><del>-       }
-       
</del><span class="cx">   /**
</span><del>-        * Test the image created with WP_Image_Edior_GD preserves alpha with no resizing etc
-        * 
</del><ins>+         * Test the image created with WP_Image_Editor_GD preserves alpha with no resizing etc
+        *
</ins><span class="cx">    * @ticket 23039
</span><span class="cx">   */
</span><span class="cx">  public function test_image_preserves_alpha() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/transparent.png';
</span><span class="cx"> 
</span><span class="cx">          $editor = wp_get_image_editor( $file );
</span><span class="cx">          $editor->load();
</span><span class="cx"> 
</span><span class="cx">          $save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
</span><del>-               
</del><ins>+
</ins><span class="cx">           $editor->save( $save_to_file );
</span><span class="cx"> 
</span><span class="cx">          $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 );
</span><span class="cx">  }
</span><del>-
</del><span class="cx"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsimageeditor_imagickphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/phpunit/tests/image/editor_imagick.php (27793 => 27794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/phpunit/tests/image/editor_imagick.php       2014-03-27 20:26:24 UTC (rev 27793)
+++ trunk/tests/phpunit/tests/image/editor_imagick.php  2014-03-27 20:39:08 UTC (rev 27794)
</span><span class="lines">@@ -11,24 +11,27 @@
</span><span class="cx"> 
</span><span class="cx">  public $editor_engine = 'WP_Image_Editor_Imagick';
</span><span class="cx"> 
</span><del>-       public function setup() {
</del><ins>+        public function setUp() {
</ins><span class="cx">           require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' );
</span><span class="cx">          require_once( ABSPATH . WPINC . '/class-wp-image-editor-imagick.php' );
</span><span class="cx"> 
</span><del>-               $editor = new WP_Image_Editor_Imagick( null );
</del><ins>+                parent::setUp();
+       }
</ins><span class="cx"> 
</span><del>-               if ( ! $editor->test() )
-                       $this->markTestSkipped( 'Image Magick not available' );
</del><ins>+        public function shutDown() {
+               $folder = DIR_TESTDATA . '/images/waffles-*.jpg';
</ins><span class="cx"> 
</span><del>-               parent::setUp();
</del><ins>+                foreach ( glob( $folder ) as $file ) {
+                       unlink( $file );
+               }
+
+               parent::shutDown();
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Check support for Image Magick compatible mime types.
-        * 
</del><ins>+         * Check support for ImageMagick compatible mime types.
</ins><span class="cx">    */
</span><span class="cx">  public function test_supports_mime_type() {
</span><del>-
</del><span class="cx">           $imagick_image_editor = new WP_Image_Editor_Imagick( null );
</span><span class="cx"> 
</span><span class="cx">          $this->assertTrue( $imagick_image_editor->supports_mime_type( 'image/jpeg' ), 'Does not support image/jpeg' );
</span><span class="lines">@@ -38,41 +41,362 @@
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Test resizing an image, not using crop
</span><del>-        * 
</del><span class="cx">    */
</span><span class="cx">  public function test_resize() {
</span><ins>+               $file = DIR_TESTDATA . '/images/waffles.jpg';
</ins><span class="cx"> 
</span><del>-               $file = DIR_TESTDATA . '/images/gradient-square.jpg';
-
</del><span class="cx">           $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
</span><span class="cx">          $imagick_image_editor->load();
</span><span class="cx"> 
</span><span class="cx">          $imagick_image_editor->resize( 100, 50 );
</span><span class="cx"> 
</span><del>-               $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $imagick_image_editor->get_size() );
</del><ins>+                $this->assertEquals(
+                       array(
+                               'width'  => 75,
+                               'height' => 50,
+                       ),
+                       $imagick_image_editor->get_size()
+               );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Test resizing an image including cropping
-        * 
</del><ins>+         * Test multi_resize with single image resize and no crop
</ins><span class="cx">    */
</span><del>-       public function test_resize_and_crop() {
</del><ins>+        public function test_single_multi_resize() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
</ins><span class="cx"> 
</span><del>-               $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</del><ins>+                $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
+               $imagick_image_editor->load();
</ins><span class="cx"> 
</span><ins>+               $sizes_array =  array(
+                       array(
+                               'width'  => 50,
+                               'height' => 50,
+                       ),
+               );
+
+               $resized = $imagick_image_editor->multi_resize( $sizes_array );
+
+               # First, check to see if returned array is as expected
+               $expected_array = array(
+                       array(
+                               'file'      => 'waffles-50x33.jpg',
+                               'width'     => 50,
+                               'height'    => 33,
+                               'mime-type' => 'image/jpeg',
+                       ),
+               );
+
+               $this->assertEquals( $expected_array, $resized );
+
+               // Now, verify real dimensions are as expected
+               $image_path = DIR_TESTDATA . '/images/'. $resized[0]['file'];
+               $this->assertImageDimensions(
+                       $image_path,
+                       $expected_array[0]['width'],
+                       $expected_array[0]['height']
+               );
+       }
+
+       /**
+        * Ensure multi_resize doesn't create an image when
+        * both height and weight are missing, null, or 0.
+        *
+        * ticket 26823
+        */
+       public function test_multi_resize_does_not_create() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
+
</ins><span class="cx">           $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
</span><span class="cx">          $imagick_image_editor->load();
</span><span class="cx"> 
</span><ins>+               $sizes_array = array(
+                       array(
+                               'width'  => 0,
+                               'height' => 0,
+                       ),
+                       array(
+                               'width'  => 0,
+                               'height' => 0,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => null,
+                               'height' => null,
+                       ),
+                       array(
+                               'width'  => null,
+                               'height' => null,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => '',
+                               'height' => '',
+                       ),
+                       array(
+                               'width'  => '',
+                               'height' => '',
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => 0,
+                       ),
+                       array(
+                               'width'  => 0,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => null,
+                       ),
+                       array(
+                               'width'  => null,
+                               'crop'   => true,
+                       ),
+                       array(
+                               'width'  => '',
+                       ),
+                       array(
+                               'width'  => '',
+                               'crop'   => true,
+                       ),
+               );
+
+               $resized = $imagick_image_editor->multi_resize( $sizes_array );
+
+               // If no images are generated, the returned array is empty.
+               $this->assertEmpty( $resized );
+       }
+
+       /**
+        * Test multi_resize with multiple sizes
+        *
+        * ticket 26823
+        */
+       public function test_multi_resize() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
+
+               $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
+               $imagick_image_editor->load();
+
+               $sizes_array = array(
+
+                       /**
+                        * #0 - 10x10 resize, no cropping.
+                        * By aspect, should be 10x6 output.
+                        */
+                       array(
+                               'width'  => 10,
+                               'height' => 10,
+                               'crop'   => false,
+                       ),
+
+                       /**
+                        * #1 - 75x50 resize, with cropping.
+                        * Output dimensions should be 75x50
+                        */
+                       array(
+                               'width'  => 75,
+                               'height' => 50,
+                               'crop'   => true,
+                       ),
+
+                       /**
+                        * #2 - 20 pixel max height, no cropping.
+                        * By aspect, should be 30x20 output.
+                        */
+                       array(
+                               'width'  => 9999, # Arbitrary High Value
+                               'height' => 20,
+                               'crop'   => false,
+                       ),
+
+                       /**
+                        * #3 - 45 pixel max height, with cropping.
+                        * By aspect, should be 45x400 output.
+                        */
+                       array(
+                               'width'  => 45,
+                               'height' => 9999, # Arbitrary High Value
+                               'crop'   => true,
+                       ),
+
+                       /**
+                        * #4 - 50 pixel max width, no cropping.
+                        * By aspect, should be 50x33 output.
+                        */
+                       array(
+                               'width' => 50,
+                       ),
+
+                       /**
+                        * #5 - 55 pixel max width, no cropping, null height
+                        * By aspect, should be 55x36 output.
+                        */
+                       array(
+                               'width'  => 55,
+                               'height' => null,
+                       ),
+
+                       /**
+                        * #6 - 55 pixel max height, no cropping, no width specified.
+                        * By aspect, should be 82x55 output.
+                        */
+                       array(
+                               'height' => 55,
+                       ),
+
+                       /**
+                        * #7 - 60 pixel max height, no cropping, null width.
+                        * By aspect, should be 90x60 output.
+                        */
+                       array(
+                               'width'  => null,
+                               'height' => 60,
+                       ),
+
+                       /**
+                        * #8 - 70 pixel max height, no cropping, negative width.
+                        * By aspect, should be 105x70 output.
+                        */
+                       array(
+                               'width'  => -9999, # Arbitrary Negative Value
+                               'height' => 70,
+                       ),
+
+                       /**
+                        * #9 - 200 pixel max width, no cropping, negative height.
+                        * By aspect, should be 200x133 output.
+                        */
+                       array(
+                               'width'  => 200,
+                               'height' => -9999, # Arbitrary Negative Value
+                       ),
+               );
+
+               $resized = $imagick_image_editor->multi_resize( $sizes_array );
+
+               $expected_array = array(
+
+                       // #0
+                       array(
+                               'file'      => 'waffles-10x6.jpg',
+                               'width'     => 10,
+                               'height'    => 6,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #1
+                       array(
+                               'file'      => 'waffles-75x50.jpg',
+                               'width'     => 75,
+                               'height'    => 50,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #2
+                       array(
+                               'file'      => 'waffles-30x20.jpg',
+                               'width'     => 30,
+                               'height'    => 20,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #3
+                       array(
+                               'file'      => 'waffles-45x400.jpg',
+                               'width'     => 45,
+                               'height'    => 400,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #4
+                       array(
+                               'file'      => 'waffles-50x33.jpg',
+                               'width'     => 50,
+                               'height'    => 33,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #5
+                       array(
+                               'file'      => 'waffles-55x36.jpg',
+                               'width'     => 55,
+                               'height'    => 36,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #6
+                       array(
+                               'file'      => 'waffles-82x55.jpg',
+                               'width'     => 82,
+                               'height'    => 55,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #7
+                       array(
+                               'file'      => 'waffles-90x60.jpg',
+                               'width'     => 90,
+                               'height'    => 60,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #8
+                       array(
+                               'file'      => 'waffles-105x70.jpg',
+                               'width'     => 105,
+                               'height'    => 70,
+                               'mime-type' => 'image/jpeg',
+                       ),
+
+                       // #9
+                       array(
+                               'file'      => 'waffles-200x133.jpg',
+                               'width'     => 200,
+                               'height'    => 133,
+                               'mime-type' => 'image/jpeg',
+                       ),
+               );
+
+               $this->assertNotNull( $resized );
+               $this->assertEquals( $expected_array, $resized );
+
+               foreach( $resized as $key => $image_data ){
+                       $image_path = DIR_TESTDATA . '/images/' . $image_data['file'];
+
+                       // Now, verify real dimensions are as expected
+                       $this->assertImageDimensions(
+                               $image_path,
+                               $expected_array[$key]['width'],
+                               $expected_array[$key]['height']
+                       );
+               }
+       }
+
+       /**
+        * Test resizing an image with cropping
+        */
+       public function test_resize_and_crop() {
+               $file = DIR_TESTDATA . '/images/waffles.jpg';
+
+               $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
+               $imagick_image_editor->load();
+
</ins><span class="cx">           $imagick_image_editor->resize( 100, 50, true );
</span><span class="cx"> 
</span><del>-               $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $imagick_image_editor->get_size() );
</del><ins>+                $this->assertEquals(
+                       array(
+                               'width'  => 100,
+                               'height' => 50,
+                       ),
+                       $imagick_image_editor->get_size()
+               );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Test cropping an image
</span><span class="cx">   */
</span><span class="cx">  public function test_crop() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</span><span class="cx"> 
</span><span class="cx">          $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
</span><span class="lines">@@ -80,15 +404,19 @@
</span><span class="cx"> 
</span><span class="cx">          $imagick_image_editor->crop( 0, 0, 50, 50 );
</span><span class="cx"> 
</span><del>-               $this->assertEquals( array( 'width' => 50, 'height' => 50 ), $imagick_image_editor->get_size() );
-
</del><ins>+                $this->assertEquals(
+                       array(
+                               'width' => 50,
+                               'height' => 50,
+                       ),
+                       $imagick_image_editor->get_size()
+               );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Test rotating an image 180 deg
</span><span class="cx">   */
</span><span class="cx">  public function test_rotate() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</span><span class="cx"> 
</span><span class="cx">          $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
</span><span class="lines">@@ -108,7 +436,6 @@
</span><span class="cx">   * Test flipping an image
</span><span class="cx">   */
</span><span class="cx">  public function test_flip() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/gradient-square.jpg';
</span><span class="cx"> 
</span><span class="cx">          $imagick_image_editor = new WP_Image_Editor_Imagick( $file );
</span><span class="lines">@@ -125,39 +452,36 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Test the image created with WP_Image_Edior_Imagick preserves alpha when resizing
</del><ins>+         * Test the image created with WP_Image_Editor_Imagick preserves alpha when resizing
</ins><span class="cx">    *
</span><span class="cx">   * @ticket 24871
</span><span class="cx">   */
</span><span class="cx">  public function test_image_preserves_alpha_on_resize() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/transparent.png';
</span><span class="cx"> 
</span><span class="cx">          $editor = wp_get_image_editor( $file );
</span><span class="cx">          $editor->load();
</span><del>-               $editor->resize(5,5);
</del><ins>+                $editor->resize( 5, 5 );
</ins><span class="cx">           $save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
</span><span class="cx">          
</span><span class="cx">          $editor->save( $save_to_file );
</span><span class="cx"> 
</span><span class="cx">          $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 );
</span><ins>+       }
</ins><span class="cx"> 
</span><del>-       }
-       
</del><span class="cx">   /**
</span><del>-        * Test the image created with WP_Image_Edior_Imagick preserves alpha with no resizing etc
</del><ins>+         * Test the image created with WP_Image_Editor_Imagick preserves alpha with no resizing etc
</ins><span class="cx">    *
</span><span class="cx">   * @ticket 24871
</span><span class="cx">   */
</span><span class="cx">  public function test_image_preserves_alpha() {
</span><del>-
</del><span class="cx">           $file = DIR_TESTDATA . '/images/transparent.png';
</span><span class="cx"> 
</span><span class="cx">          $editor = wp_get_image_editor( $file );
</span><span class="cx">          $editor->load();
</span><span class="cx"> 
</span><span class="cx">          $save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
</span><del>-               
</del><ins>+
</ins><span class="cx">           $editor->save( $save_to_file );
</span><span class="cx"> 
</span><span class="cx">          $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 );
</span></span></pre>
</div>
</div>

</body>
</html>