WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/12/2013 02:47:58 PM (6 years ago)
Author:
wonderboymusic
Message:

There was way too much duplicated code in my notice cleanup, it built up over time, and there's definitely a need to standardize.

  • Remove duplicated code for deprecated function notice suppression
  • Add support in WP_UnitTestCase setUp/tearDown methods for $deprecated_functions fixture if the extending class has added it
  • Add a $deprecated_functions fixture to each extending class that needs it

To use this fixture, add something to your Test Case class like so:
protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );

See #25282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesTheme.php

    r25362 r25402  
    44 */
    55class Tests_Admin_includesTheme extends WP_UnitTestCase {
     6    protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );
     7
    68    function setUp() {
    79        parent::setUp();
     
    1820        wp_clean_themes_cache();
    1921        unset( $GLOBALS['wp_themes'] );
    20        
    21         add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
    22     }
    23 
    24     function deprecated_function_run_check( $function ) {
    25         if ( in_array( $function, array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' ) ) )
    26             add_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
    27     }
    28 
    29     function filter_deprecated_function_trigger_error() {
    30         remove_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
    31         return false;
    3222    }
    3323
Note: See TracChangeset for help on using the changeset viewer.