mirror of
git://develop.git.wordpress.org/
synced 2025-02-22 15:42:29 +01:00
Build/Test Tools: Add documentation for tests_add_filter()
, _test_filter_build_unique_id()
, _delete_all_data()
, _delete_all_posts()
.
Props andizer. Fixes #44703. git-svn-id: https://develop.svn.wordpress.org/trunk@43555 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
49a6596d7e
commit
4ce3db3e8d
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user