Ticket #17814: 17814.test.diff

File 17814.test.diff, 999 bytes (added by DH-Shredder, 8 months ago)

Initial Unit Test.

Line 
1Index: tests/image/functions.php
2===================================================================
3--- tests/image/functions.php   (revision 1066)
4+++ tests/image/functions.php   (working copy)
5@@ -219,4 +219,27 @@
6                        unset( $img );
7                }
8        }
9+
10+       /**
11+        * Try loading a directory
12+        * @ticket 17814
13+        */
14+       public function test_load_directory() {
15+               // First, test with deprecated wp_load_image function
16+               $editor = wp_load_image( DIR_TESTDATA );
17+               $this->assertNotInternalType( 'resource', $editor );
18+
19+               // Then, test with editors.
20+               $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
21+               foreach ( $classes as $class ) {
22+                       if ( !$class::test() ) {
23+                               continue;
24+                       }
25+                       $filter = create_function( '', "return '$class';" );
26+                       add_filter( 'image_editor_class', $filter );
27+                       $editor = WP_Image_Editor::get_instance( DIR_TESTDATA );
28+                       $this->assertInstanceOf( 'WP_Error', $editor );
29+                       $this->assertEquals( 'error_loading_image', $editor->get_error_code() );
30+               }
31+       }
32 }