Make WordPress Core

Changeset 1120 in tests for trunk/tests/image/functions.php


Ignore:
Timestamp:
11/08/2012 01:56:36 AM (14 years ago)
Author:
nacin
Message:

Unit test for wp_load_image() / WP_Image_Editor trying to load a directory. props DH-Shredder. see #WP17814.

File:
1 edited

Legend:

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

    r1075 r1120  
    220220                }
    221221        }
     222
     223        /**
     224         * Try loading a directory
     225         * @ticket 17814
     226         */
     227        public function test_load_directory() {
     228                // First, test with deprecated wp_load_image function
     229                $editor = wp_load_image( DIR_TESTDATA );
     230                $this->assertNotInternalType( 'resource', $editor );
     231
     232                // Then, test with editors.
     233                $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
     234                foreach ( $classes as $class ) {
     235                        if ( !$class::test() ) {
     236                                continue;
     237                        }
     238                        $filter = create_function( '', "return '$class';" );
     239                        add_filter( 'image_editor_class', $filter );
     240                        $editor = WP_Image_Editor::get_instance( DIR_TESTDATA );
     241                        $this->assertInstanceOf( 'WP_Error', $editor );
     242                        $this->assertEquals( 'error_loading_image', $editor->get_error_code() );
     243                }
     244        }
    222245}
Note: See TracChangeset for help on using the changeset viewer.