Make WordPress Core


Ignore:
Timestamp:
09/12/2013 04:40:13 AM (13 years ago)
Author:
wonderboymusic
Message:
  • Avoid notice by making WP_Image_Editor_Mock::test() compatible with WP_Image_Editor::test().
  • Suppress deprecated function notice for wp_load_image().
  • Add assertion for wp_get_image_editor().

See #25282.

File:
1 edited

Legend:

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

    r25002 r25380  
    1010         * Setup test fixture
    1111         */
    12         public function setup() {
     12        public function setUp() {
     13                parent::setUp();
     14
    1315                require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' );
    1416                require_once( ABSPATH . WPINC . '/class-wp-image-editor-gd.php' );
    … …  
    1618
    1719                include_once( DIR_TESTDATA . '/../includes/mock-image-editor.php' );
     20                add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
     21        }
     22
     23        function tearDown() {
     24                parent::tearDown();
     25                remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
     26        }
     27
     28        function deprecated_function_run( $function ) {
     29                if ( in_array( $function, array( 'wp_load_image' ) ) )
     30                        add_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) );
     31        }
     32
     33        function deprecated_function_trigger_error() {
     34                remove_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) );
     35                return false;
    1836        }
    1937
    … …  
    237255
    238256                // First, test with deprecated wp_load_image function
    239                 $editor = wp_load_image( DIR_TESTDATA );
    240                 $this->assertNotInternalType( 'resource', $editor );
     257                $editor1 = wp_load_image( DIR_TESTDATA );
     258                $this->assertNotInternalType( 'resource', $editor1 );
     259
     260                $editor2 = wp_get_image_editor( DIR_TESTDATA );
     261                $this->assertNotInternalType( 'resource', $editor2 );
    241262
    242263                // Then, test with editors.
Note: See TracChangeset for help on using the changeset viewer.