mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-05 15:16:59 +00:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user