Make WordPress Core

Changeset 1201 in tests


Ignore:
Timestamp:
02/02/2013 01:50:23 AM (14 years ago)
Author:
SergeyBiryukov
Message:

wp_crop_image() test for error on saving. see #23325.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/mock-image-editor.php

    r1151 r1201  
    77                public static $load_return = true;
    88                public static $test_return = true;
     9                public static $save_return = array();
    910
    1011                public function load() {
    … …  
    3334                }
    3435                public function save( $destfilename = null, $mime_type = null ) {
    35 
     36                        return self::$save_return;
    3637                }
    3738                public function stream( $mime_type = null ) {
  • trunk/tests/image/functions.php

    r1200 r1201  
    77 */
    88class Tests_Image_Functions extends WP_UnitTestCase {
    9 
    109        /**
    1110         * Setup test fixture
    1211         */
    1312        public function setup() {
    14                 require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    15                 require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    16                 require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
     13                require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' );
     14                require_once( ABSPATH . WPINC . '/class-wp-image-editor-gd.php' );
     15                require_once( ABSPATH . WPINC . '/class-wp-image-editor-imagick.php' );
     16
     17                include_once( DIR_TESTDATA . '/../includes/mock-image-editor.php' );
    1718        }
    1819
    … …  
    299300                $this->assertInstanceOf( 'WP_Error', $file );
    300301        }
     302
     303        function mock_image_editor( $editors ) {
     304                return array( 'WP_Image_Editor_Mock' );
     305        }
     306
     307        /**
     308         * @ticket 23325
     309         */
     310        public function test_wp_crop_image_error_on_saving() {
     311                WP_Image_Editor_Mock::$save_return = new WP_Error();
     312                add_filter( 'wp_image_editors', array( $this, 'mock_image_editor' ) );
     313
     314                $file = wp_crop_image( DIR_TESTDATA . '/images/canola.jpg',
     315                                                          0, 0, 100, 100, 100, 100 );
     316                $this->assertInstanceOf( 'WP_Error', $file );
     317
     318                remove_filter( 'wp_image_editors', array( $this, 'mock_image_editor' ) );
     319                WP_Image_Editor_Mock::$save_return = array();
     320        }
    301321}
Note: See TracChangeset for help on using the changeset viewer.