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
+2 -17
View File
@@ -7,7 +7,8 @@
* @group capabilities
*/
class Tests_User_Capabilities extends WP_UnitTestCase {
var $user_ids = array();
protected $user_ids = array();
protected $deprecated_functions = array( 'set_current_user' );
function setUp() {
parent::setUp();
@@ -15,22 +16,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
$this->_flush_roles();
$this->orig_users = get_users();
add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
}
function tearDown() {
parent::tearDown();
remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
}
function deprecated_function_run( $function ) {
if ( in_array( $function, array( 'set_current_user' ) ) )
add_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) );
}
function deprecated_function_trigger_error() {
remove_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) );
return false;
}
function _flush_roles() {