Changeset 29503
- Timestamp:
- 08/15/2014 03:40:48 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r29274 r29503 68 68 69 69 /** 70 * Saves the action and filter-related globals so they can be restored later 70 * Saves the action and filter-related globals so they can be restored later. 71 71 * 72 72 * Stores $merged_filters, $wp_actions, $wp_current_filter, and $wp_filter 73 * on a class variable so they can be restored on tearDown() using _restore_hooks() 74 * @global array $merged_filters 75 * @global array $wp_actions 76 * @global array $wp_current_filter 77 * @global array $wp_filter 78 * @return void 79 */ 80 protected function _backup_hooks() { 81 $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); 82 foreach ( $globals as $key ) { 83 self::$hooks_saved[ $key ] = $GLOBALS[ $key ]; 84 } 85 } 86 87 /** 88 * Restores the hook-related globals to their state at setUp() 89 * 90 * so that future tests aren't affected by hooks set during this last test 73 * on a class variable so they can be restored on tearDown() using _restore_hooks(). 91 74 * 92 75 * @global array $merged_filters … … 96 79 * @return void 97 80 */ 98 protected function _ restore_hooks(){81 protected function _backup_hooks() { 99 82 $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); 100 83 foreach ( $globals as $key ) { 101 $GLOBALS[ $key ] = self::$hooks_saved[ $key ]; 84 self::$hooks_saved[ $key ] = $GLOBALS[ $key ]; 85 } 86 } 87 88 /** 89 * Restores the hook-related globals to their state at setUp() 90 * so that future tests aren't affected by hooks set during this last test. 91 * 92 * @global array $merged_filters 93 * @global array $wp_actions 94 * @global array $wp_current_filter 95 * @global array $wp_filter 96 * @return void 97 */ 98 protected function _restore_hooks() { 99 $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); 100 foreach ( $globals as $key ) { 101 if ( isset( self::$hooks_saved[ $key ] ) ) { 102 $GLOBALS[ $key ] = self::$hooks_saved[ $key ]; 103 } 102 104 } 103 105 }
Note: See TracChangeset
for help on using the changeset viewer.