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.



git-svn-id: https://develop.svn.wordpress.org/trunk@25402 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2013-09-12 14:47:58 +00:00
parent 1851da1382
commit 654d07ebf9
10 changed files with 32 additions and 148 deletions
+1 -17
View File
@@ -8,29 +8,13 @@ if ( is_multisite() ) :
* @group multisite
*/
class Tests_MS extends WP_UnitTestCase {
protected $deprecated_functions = array( 'is_blog_user', 'get_dashboard_blog' );
protected $plugin_hook_count = 0;
function setUp() {
parent::setUp();
$_SERVER['REMOTE_ADDR'] = '';
add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
}
function tearDown() {
parent::tearDown();
remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
}
function deprecated_function_run_check( $function ) {
if ( in_array( $function, array( 'is_blog_user', 'get_dashboard_blog' ) ) )
add_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
}
function filter_deprecated_function_trigger_error() {
remove_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
return false;
}
function test_create_and_delete_blog() {