WordPress.org

Make WordPress Core

Changeset 1151 in tests


Ignore:
Timestamp:
11/22/12 10:19:38 (17 months ago)
Author:
nacin
Message:

Tests for [WP22817], see #WP22356. props DH-Shredder.

Location:
trunk
Files:
3 edited

Legend:

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

    r1148 r1151  
    88        public static $test_return = true; 
    99 
    10         protected function load() { 
     10        public function load() { 
    1111            return self::$load_return; 
    1212        } 
  • trunk/tests/image/editor.php

    r1123 r1151  
    1818     */ 
    1919    public function setup() { 
    20         if ( !class_exists( 'WP_Image_Editor' ) ) 
    21             $this->markTestSkipped(); 
    22  
    23         // Include our custom mock 
     20        require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' ); 
     21 
    2422        include_once( DIR_TESTDATA . '/../includes/mock-image-editor.php' ); 
    2523 
     
    6260 
    6361    /** 
    64      * Test get_instance where load returns true 
    65      * @ticket 6821 
    66      */ 
    67     public function test_get_instance_load_returns_true() { 
     62     * Test wp_get_image_editor() where load returns true 
     63     * @ticket 6821 
     64     */ 
     65    public function test_get_editor_load_returns_true() { 
    6866 
    6967        // Swap out the PHPUnit mock with our custom mock 
     
    7674 
    7775        // Load an image 
    78         $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     76        $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    7977 
    8078        // Everything should work 
     
    8684 
    8785    /** 
    88      * Test get_instance where load returns false 
    89      * @ticket 6821 
    90      */ 
    91     public function test_get_instance_load_returns_false() { 
     86     * Test wp_get_image_editor() where load returns false 
     87     * @ticket 6821 
     88     */ 
     89    public function test_get_editor_load_returns_false() { 
    9290 
    9391        // Swap out the PHPUnit mock with our custom mock 
     
    10098 
    10199        // Load an image 
    102         $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     100        $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    103101 
    104102        // Everything should work 
     
    116114 
    117115        // Get an editor 
    118         $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     116        $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    119117 
    120118        // Make quality readable 
     
    143141 
    144142        // Get an editor 
    145         $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     143        $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
     144 
    146145        $property = new ReflectionProperty( $editor, 'size' ); 
    147146        $property->setAccessible( true ); 
     
    173172    public function test_get_size() { 
    174173 
    175         $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     174        $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    176175 
    177176        // Size should be false by default 
     
    195194     */ 
    196195    public function test_get_suffix() { 
    197         $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     196        $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    198197 
    199198        // Size should be false by default 
  • trunk/tests/image/functions.php

    r1148 r1151  
    77 */ 
    88class Tests_Image_Functions extends WP_UnitTestCase { 
     9 
     10    /** 
     11     * Setup test fixture 
     12     */ 
     13    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'; 
     17    } 
    918 
    1019    /** 
     
    121130 
    122131            // Call wp_save_image_file 
    123             $img = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     132            $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    124133 
    125134            // Save a file as each mime type, assert it works 
     
    159168 
    160169            // Save the file 
    161             $img = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     170            $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    162171            $mime_type = 'image/gif'; 
    163172            $file = wp_tempnam( 'tmp.jpg' ); 
     
    204213 
    205214            // Save the image as each file extension, check the mime type 
    206             $img = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' ); 
     215            $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 
    207216            $temp = get_temp_dir(); 
    208217            foreach ( $mime_types as $ext => $mime_type ) { 
     
    226235     */ 
    227236    public function test_load_directory() { 
     237 
    228238        // First, test with deprecated wp_load_image function 
    229239        $editor = wp_load_image( DIR_TESTDATA ); 
     
    238248            $filter = create_function( '', "return '$class';" ); 
    239249            add_filter( 'image_editor_class', $filter ); 
    240             $editor = WP_Image_Editor::get_instance( DIR_TESTDATA ); 
     250            $editor = wp_get_image_editor( DIR_TESTDATA ); 
    241251            $this->assertInstanceOf( 'WP_Error', $editor ); 
    242252            $this->assertEquals( 'error_loading_image', $editor->get_error_code() ); 
     
    249259        $this->assertNotInstanceOf( 'WP_Error', $file ); 
    250260        $this->assertFileExists( $file ); 
    251         $image = WP_Image_Editor::get_instance( $file ); 
     261        $image = wp_get_image_editor( $file ); 
    252262        $size = $image->get_size(); 
    253263        $this->assertEquals( 100, $size['height'] ); 
     
    261271        $this->assertNotInstanceOf( 'WP_Error', $file ); 
    262272        $this->assertFileExists( $file ); 
    263         $image = WP_Image_Editor::get_instance( $file ); 
     273        $image = wp_get_image_editor( $file ); 
    264274        $size = $image->get_size(); 
    265275        $this->assertEquals( 100, $size['height'] ); 
Note: See TracChangeset for help on using the changeset viewer.