From 4196a0751c595e2b44cea02c582e4c268155cef4 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 26 Sep 2015 22:02:15 +0000 Subject: [PATCH] Add function signature tests for the pluggable functions in `wp-includes/cache.php`. See #33867 git-svn-id: https://develop.svn.wordpress.org/trunk@34607 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/pluggable.php | 37 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/pluggable.php b/tests/phpunit/tests/pluggable.php index 464638d761..b8efdb59dd 100644 --- a/tests/phpunit/tests/pluggable.php +++ b/tests/phpunit/tests/pluggable.php @@ -74,14 +74,20 @@ class Tests_Pluggable extends WP_UnitTestCase { */ public function getDefinedPluggableFunctions() { - preg_match_all( '#^function (\w+)#m', file_get_contents( ABSPATH . '/wp-includes/pluggable.php' ), $functions ); - + $test_files = array( + 'wp-includes/pluggable.php', + 'wp-includes/cache.php', + ); $data = array(); - foreach ( $functions[1] as $function ) { - $data[] = array( - $function, - ); + foreach ( $test_files as $file ) { + preg_match_all( '#^function (\w+)#m', file_get_contents( ABSPATH . '/' . $file ), $functions ); + + foreach ( $functions[1] as $function ) { + $data[] = array( + $function + ); + } } return $data; @@ -96,6 +102,8 @@ class Tests_Pluggable extends WP_UnitTestCase { public function getPluggableFunctionSignatures() { return array( + + // wp-includes/pluggable.php: 'wp_set_current_user' => array( 'id', 'name' => '' ), 'wp_get_current_user' => array(), 'get_currentuserinfo' => array(), @@ -135,6 +143,23 @@ class Tests_Pluggable extends WP_UnitTestCase { 'wp_set_password' => array( 'password', 'user_id' ), 'get_avatar' => array( 'id_or_email', 'size' => 96, 'default' => '', 'alt' => '', 'args' => null ), 'wp_text_diff' => array( 'left_string', 'right_string', 'args' => null ), + + // wp-includes/cache.php: + 'wp_cache_add' => array( 'key', 'data', 'group' => '', 'expire' => 0 ), + 'wp_cache_close' => array(), + 'wp_cache_decr' => array( 'key', 'offset' => 1, 'group' => '' ), + 'wp_cache_delete' => array( 'key', 'group' => '' ), + 'wp_cache_flush' => array(), + 'wp_cache_get' => array( 'key', 'group' => '', 'force' => false, 'found' => null ), + 'wp_cache_incr' => array( 'key', 'offset' => 1, 'group' => '' ), + 'wp_cache_init' => array(), + 'wp_cache_replace' => array( 'key', 'data', 'group' => '', 'expire' => 0 ), + 'wp_cache_set' => array( 'key', 'data', 'group' => '', 'expire' => 0 ), + 'wp_cache_switch_to_blog' => array( 'blog_id' ), + 'wp_cache_add_global_groups' => array( 'groups' ), + 'wp_cache_add_non_persistent_groups' => array( 'groups' ), + 'wp_cache_reset' => array(), + ); }