mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Avoid undefined index notices in WP_UnitTestCase::_restore_hooks().
props kevinlangleyjr. fixes #29123. git-svn-id: https://develop.svn.wordpress.org/trunk@29503 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b6f0d0c208
commit
262929004d
@ -67,10 +67,11 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the action and filter-related globals so they can be restored later
|
||||
* Saves the action and filter-related globals so they can be restored later.
|
||||
*
|
||||
* Stores $merged_filters, $wp_actions, $wp_current_filter, and $wp_filter
|
||||
* on a class variable so they can be restored on tearDown() using _restore_hooks()
|
||||
* on a class variable so they can be restored on tearDown() using _restore_hooks().
|
||||
*
|
||||
* @global array $merged_filters
|
||||
* @global array $wp_actions
|
||||
* @global array $wp_current_filter
|
||||
@ -86,8 +87,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Restores the hook-related globals to their state at setUp()
|
||||
*
|
||||
* so that future tests aren't affected by hooks set during this last test
|
||||
* so that future tests aren't affected by hooks set during this last test.
|
||||
*
|
||||
* @global array $merged_filters
|
||||
* @global array $wp_actions
|
||||
@ -95,10 +95,12 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
* @global array $wp_filter
|
||||
* @return void
|
||||
*/
|
||||
protected function _restore_hooks(){
|
||||
protected function _restore_hooks() {
|
||||
$globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' );
|
||||
foreach ( $globals as $key ) {
|
||||
$GLOBALS[ $key ] = self::$hooks_saved[ $key ];
|
||||
if ( isset( self::$hooks_saved[ $key ] ) ) {
|
||||
$GLOBALS[ $key ] = self::$hooks_saved[ $key ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user