From 8453d41a44aa81e37fc2b789a27ea36a3f30c8d3 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 20 Apr 2015 09:40:11 +0000 Subject: [PATCH] Fix the unit test added in [32173] to run correctly in PHP 5.2. git-svn-id: https://develop.svn.wordpress.org/trunk@32177 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/capabilities.php | 32 +++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index 8458697d11..6a1044b55c 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -704,30 +704,28 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $orig_blog_id = get_current_blog_id(); $blog_id = $this->factory->blog->create(); - $nullify_current_user = function() { - // Prevents fatal errors in ::tearDown()'s and other uses of restore_current_blog() - $function_stack = wp_debug_backtrace_summary( null, 0, false ); - if ( in_array( 'restore_current_blog', $function_stack ) ) { - return; - } - $GLOBALS['current_user'] = null; - }; + $this->_nullify_current_user(); - $nullify_current_user_and_keep_nullifying_user = function() use ( $nullify_current_user ) { - $nullify_current_user(); - - add_action( 'set_current_user', $nullify_current_user ); - }; - - $nullify_current_user(); - - add_action( 'switch_blog', $nullify_current_user_and_keep_nullifying_user ); + add_action( 'switch_blog', array( $this, '_nullify_current_user_and_keep_nullifying_user' ) ); current_user_can_for_blog( $blog_id, 'edit_posts' ); $this->assertEquals( $orig_blog_id, get_current_blog_id() ); } + function _nullify_current_user() { + // Prevents fatal errors in ::tearDown()'s and other uses of restore_current_blog() + $function_stack = wp_debug_backtrace_summary( null, 0, false ); + if ( in_array( 'restore_current_blog', $function_stack ) ) { + return; + } + $GLOBALS['current_user'] = null; + } + + function _nullify_current_user_and_keep_nullifying_user() { + add_action( 'set_current_user', array( $this, '_nullify_current_user' ) ); + } + /** * @ticket 28374 */