diff --git a/tests/phpunit/includes/functions.php b/tests/phpunit/includes/functions.php index 696741166e..17bc879ec1 100644 --- a/tests/phpunit/includes/functions.php +++ b/tests/phpunit/includes/functions.php @@ -16,7 +16,15 @@ function tests_reset__SERVER() { unset( $_SERVER['HTTPS'] ); } -// For adding hooks before loading WP +/** + * Adds hooks before loading WP. + * + * @param string $tag The name for the filter to add. + * @param object|array $function_to_add The function/callback to execute on call. + * @param int $priority The priority. + * @param int $accepted_args The amount of accepted arguments. + * @return bool Always true. + */ function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { global $wp_filter; @@ -32,13 +40,21 @@ function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_arg return true; } +/** + * Generates a unique function ID based on the given arguments. + * + * @param string $tag Unused. The name of the filter to build ID for. + * @param object|array $function The function to generate ID for. + * @param int $priority Unused. The priority. + * @return string Unique function ID. + */ function _test_filter_build_unique_id( $tag, $function, $priority ) { if ( is_string( $function ) ) { return $function; } if ( is_object( $function ) ) { - // Closures are currently implemented as objects + // Closures are currently implemented as objects. $function = array( $function, '' ); } else { $function = (array) $function; @@ -47,11 +63,14 @@ function _test_filter_build_unique_id( $tag, $function, $priority ) { if ( is_object( $function[0] ) ) { return spl_object_hash( $function[0] ) . $function[1]; } elseif ( is_string( $function[0] ) ) { - // Static Calling + // Static Calling. return $function[0] . $function[1]; } } +/** + * Deletes all data from the database. + */ function _delete_all_data() { global $wpdb; @@ -79,6 +98,9 @@ function _delete_all_data() { $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id != 1" ); } +/** + * Deletes all posts from the database. + */ function _delete_all_posts() { global $wpdb;