Make WordPress Core

Changeset 1061 in tests for trunk/tests/image/resize.php


Ignore:
Timestamp:
10/01/2012 09:08:41 PM (14 years ago)
Author:
kurtpayne
Message:

Unit tests for #WP6821

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/image/resize.php

    r909 r1061  
    124124        }
    125125
     126        /**
     127         * Try resizing a non-existent image
     128         * @ticket 6821
     129         */
     130        public function test_resize_non_existent_image() {
     131                $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
     132                foreach ( $classes as $class ) {
     133                        if ( !$class::test() ) {
     134                                continue;
     135                        }
     136                        $filter = create_function( '', "return $class;" );
     137                        add_filter( 'image_editor_class', $filter );
     138                        $image = image_resize( DIR_TESTDATA.'/images/test-non-existent-image.jpg', 25, 25 );
     139                        $this->assertInstanceOf( 'WP_Error', $image );
     140                        $this->assertEquals( 'error_loading_image', $image->get_error_code() );
     141                }
     142        }
     143       
     144        /**
     145         * Try resizing a php file (bad image)
     146         * @ticket 6821
     147         */
     148        public function test_resize_bad_image() {
     149                $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
     150                foreach ( $classes as $class ) {
     151                        if ( !$class::test() ) {
     152                                continue;
     153                        }
     154                        $filter = create_function( '', "return $class;" );
     155                        add_filter( 'image_editor_class', $filter );
     156                        $image = image_resize( DIR_TESTDATA.'/export/crazy-cdata.xml', 25, 25 );
     157                        $this->assertInstanceOf( 'WP_Error', $image );
     158                        $this->assertEquals( 'invalid_image', $image->get_error_code() );
     159                }
     160        }
    126161}
Note: See TracChangeset for help on using the changeset viewer.