Ticket #3278: master...suggestions-2.patch
File master...suggestions-2.patch, 43.0 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-classes.php
diff --git a/src/bp-core/bp-core-classes.php b/src/bp-core/bp-core-classes.php index fb24188..eed9bbd 100644
a b function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { 2407 2407 $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />'; 2408 2408 } 2409 2409 } 2410 2411 /** 2412 * Base class for the BuddyPress Suggestions API. 2413 * 2414 * Originally built to power BuddyPress' at-mentions suggestions, it's flexible enough to be used 2415 * for similar kinds of future core requirements, or those desired by third-party developers. 2416 * 2417 * To implement a new suggestions service, create a new class that extends this one, and update 2418 * the list of default services in {@link bp_core_get_suggestions()}. If you're building a plugin, 2419 * it's recommend that you use the `bp_suggestions_services` filter to do this. :) 2420 * 2421 * While the implementation of the query logic is left to you, it should be as quick and efficient 2422 * as possible. When implementing the abstract methods in this class, pay close attention to the 2423 * recommendations provided in the phpDoc blocks, particularly the expected return types. 2424 * 2425 * @since BuddyPress (2.1.0) 2426 */ 2427 abstract class BP_Suggestions { 2428 2429 /** 2430 * Default arguments common to all suggestions services. 2431 * 2432 * If your custom service requires further defaults, add them here. 2433 * 2434 * @since BuddyPress (2.1.0) 2435 * @var array 2436 */ 2437 protected $default_args = array( 2438 'limit' => 16, 2439 'term' => '', 2440 'type' => '', 2441 ); 2442 2443 /** 2444 * Holds the arguments for the query (about to made to the suggestions service). 2445 * 2446 * This includes `$default_args`, as well as the user-supplied values. 2447 * 2448 * @since BuddyPress (2.1.0) 2449 * @var array 2450 */ 2451 protected $args = array( 2452 ); 2453 2454 2455 /** 2456 * Constructor. 2457 * 2458 * @param array $args Optional. If set, used as the parameters for the suggestions service query. 2459 * @since BuddyPress (2.1.0) 2460 */ 2461 public function __construct( array $args = array() ) { 2462 if ( ! empty( $args ) ) { 2463 $this->set_query( $args ); 2464 } 2465 } 2466 2467 /** 2468 * Set the parameters for the suggestions service query. 2469 * 2470 * @param array $args { 2471 * @type int $limit Maximum number of results to display. Optional, default: 16. 2472 * @type string $type The name of the suggestion service to use for the request. Mandatory. 2473 * @type string $term The suggestion service will try to find results that contain this string. 2474 * Mandatory. 2475 * } 2476 * @since BuddyPress (2.1.0) 2477 */ 2478 public function set_query( array $args = array() ) { 2479 $this->args = wp_parse_args( $args, $this->default_args ); 2480 } 2481 2482 /** 2483 * Validate and sanitise the parameters for the suggestion service query. 2484 * 2485 * Be sure to call this class' version of this method when implementing it in your own service. 2486 * If validation fails, you must return a WP_Error object. 2487 * 2488 * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool). 2489 * @since BuddyPress (2.1.0) 2490 */ 2491 public function validate() { 2492 $this->args['limit'] = absint( $this->args['limit'] ); 2493 $this->args['term'] = trim( sanitize_text_field( $this->args['term'] ) ); 2494 $this->args = apply_filters( 'bp_suggestions_args', $this->args, $this ); 2495 2496 2497 // Check for invalid or missing mandatory parameters. 2498 if ( ! $this->args['limit'] || ! $this->args['term'] ) { 2499 return new WP_Error( 'missing_parameter' ); 2500 } 2501 2502 // Check for blocked users (e.g. deleted accounts, or spammers). 2503 if ( is_user_logged_in() && ! bp_is_user_active( get_current_user_id() ) ) { 2504 return new WP_Error( 'invalid_user' ); 2505 } 2506 2507 return apply_filters( 'bp_suggestions_validate_args', true, $this ); 2508 } 2509 2510 /** 2511 * Find and return a list of suggestions that match the query. 2512 * 2513 * The return type is important. If no matches are found, an empty array must be returned. 2514 * Matches must be returned as objects in an array. 2515 * 2516 * The object format for each match must be: { 'ID': string, 'image': string, 'name': string } 2517 * For example: { 'ID': 'admin', 'image': 'http://example.com/logo.png', 'name': 'Name Surname' } 2518 * 2519 * @return array|WP_Error Array of results. If there were problems, returns a WP_Error object. 2520 * @since BuddyPress (2.1.0) 2521 */ 2522 abstract public function get_suggestions(); 2523 } 2524 2525 /** 2526 * Adds support for user at-mentions to the Suggestions API. 2527 * 2528 * This class is in the Core component because it's required by a class in the Groups component, 2529 * and Groups is loaded before Members (alphabetical order). 2530 * 2531 * @since BuddyPress (2.1.0) 2532 */ 2533 class BP_Members_Suggestions extends BP_Suggestions { 2534 2535 /** 2536 * Default arguments for this suggestions service. 2537 * 2538 * @since BuddyPress (2.1.0) 2539 * @var array $args { 2540 * @type int $limit Maximum number of results to display. Default: 16. 2541 * @type bool $only_friends If true, only match the current user's friends. Default: false. 2542 * @type string $term The suggestion service will try to find results that contain this string. 2543 * Mandatory. 2544 * } 2545 */ 2546 protected $default_args = array( 2547 'limit' => 16, 2548 'only_friends' => false, 2549 'term' => '', 2550 'type' => '', 2551 ); 2552 2553 2554 /** 2555 * Validate and sanitise the parameters for the suggestion service query. 2556 * 2557 * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool). 2558 * @since BuddyPress (2.1.0) 2559 */ 2560 public function validate() { 2561 $this->args['only_friends'] = (bool) $this->args['only_friends']; 2562 $this->args = apply_filters( 'bp_members_suggestions_args', $this->args, $this ); 2563 2564 // Check for invalid or missing mandatory parameters. 2565 if ( $this->args['only_friends'] && ( ! bp_is_active( 'friends' ) || ! is_user_logged_in() ) ) { 2566 return new WP_Error( 'missing_requirement' ); 2567 } 2568 2569 return apply_filters( 'bp_members_suggestions_validate_args', parent::validate(), $this ); 2570 } 2571 2572 /** 2573 * Find and return a list of username suggestions that match the query. 2574 * 2575 * @return array|WP_Error Array of results. If there were problems, returns a WP_Error object. 2576 * @since BuddyPress (2.1.0) 2577 */ 2578 public function get_suggestions() { 2579 $user_query = array( 2580 'count_total' => '', // Prevents total count 2581 'populate_extras' => false, 2582 'type' => 'alphabetical', 2583 2584 'page' => 1, 2585 'per_page' => $this->args['limit'], 2586 'search_terms' => $this->args['term'], 2587 ); 2588 2589 // Only return matches of friends of this user. 2590 if ( $this->args['only_friends'] && is_user_logged_in() ) { 2591 $user_query['user_id'] = get_current_user_id(); 2592 } 2593 2594 $user_query = apply_filters( 'bp_members_suggestions_query_args', $user_query, $this ); 2595 if ( is_wp_error( $user_query ) ) { 2596 return $user_query; 2597 } 2598 2599 2600 $user_query = new BP_User_Query( $user_query ); 2601 $results = array(); 2602 2603 foreach ( $user_query->results as $user ) { 2604 $result = new stdClass(); 2605 $result->ID = $user->user_nicename; 2606 $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) ); 2607 $result->name = bp_core_get_user_displayname( $user->ID ); 2608 2609 $results[] = $result; 2610 } 2611 2612 return apply_filters( 'bp_members_suggestions_get_suggestions', $results, $this ); 2613 } 2614 } 2615 No newline at end of file -
src/bp-core/bp-core-functions.php
diff --git a/src/bp-core/bp-core-functions.php b/src/bp-core/bp-core-functions.php index 9e46100..c22b882 100644
a b function bp_nav_menu_get_item_url( $slug ) { 1921 1921 1922 1922 return $nav_item_url; 1923 1923 } 1924 1925 /** Suggestions***************************************************************/ 1926 1927 /** 1928 * BuddyPress Suggestions API for types of at-mentions. 1929 * 1930 * This is used to power BuddyPress' at-mentions suggestions, but it is flexible enough to be used 1931 * for similar kinds of future requirements, or those implemented by third-party developers. 1932 * 1933 * @param array $args 1934 * @return array|WP_Error Array of results. If there were any problems, returns a WP_Error object. 1935 * @since BuddyPress (2.1.0) 1936 */ 1937 function bp_core_get_suggestions( $args ) { 1938 $args = wp_parse_args( $args ); 1939 1940 if ( ! $args['type'] ) { 1941 return new WP_Error( 'missing_parameter' ); 1942 } 1943 1944 // Members @name suggestions. 1945 if ( $args['type'] === 'members' ) { 1946 $class = 'BP_Members_Suggestions'; 1947 1948 // Members @name suggestions for users in a specific Group. 1949 if ( isset( $args['group_id'] ) ) { 1950 $class = 'BP_Groups_Member_Suggestions'; 1951 } 1952 1953 } else { 1954 // If you've built a custom suggestions service, use this to tell BP the name of your class. 1955 $class = apply_filters( 'bp_suggestions_services', '', $args ); 1956 } 1957 1958 if ( ! $class || ! class_exists( $class ) ) { 1959 return new WP_Error( 'missing_parameter' ); 1960 } 1961 1962 1963 $suggestions = new $class( $args ); 1964 $validation = $suggestions->validate(); 1965 1966 if ( is_wp_error( $validation ) ) { 1967 $retval = $validation; 1968 } else { 1969 $retval = $suggestions->get_suggestions(); 1970 } 1971 1972 return apply_filters( 'bp_core_get_suggestions', $retval, $args ); 1973 } 1974 No newline at end of file -
src/bp-friends/bp-friends-filters.php
diff --git a/src/bp-friends/bp-friends-filters.php b/src/bp-friends/bp-friends-filters.php index 6ada0e7..d91386a 100644
a b function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query 49 49 } 50 50 } 51 51 } 52 add_filter( 'bp_user_query_populate_extras', 'bp_friends_filter_user_query_populate_extras', 4, 2 ); 52 add_filter( 'bp_user_query_populate_extras', 'bp_friends_filter_user_query_populate_extras', 4, 2 ); 53 No newline at end of file -
src/bp-friends/bp-friends-functions.php
diff --git a/src/bp-friends/bp-friends-functions.php b/src/bp-friends/bp-friends-functions.php index 5f797c7..a7fddff 100644
a b function friends_remove_data( $user_id ) { 565 565 } 566 566 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 567 567 add_action( 'delete_user', 'friends_remove_data' ); 568 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 568 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 569 No newline at end of file -
src/bp-groups/bp-groups-admin.php
diff --git a/src/bp-groups/bp-groups-admin.php b/src/bp-groups/bp-groups-admin.php index 46e6a94..899b41f 100644
a b function bp_groups_admin_get_usernames_from_ids( $user_ids = array() ) { 984 984 function bp_groups_admin_autocomplete_handler() { 985 985 986 986 // Bail if user user shouldn't be here, or is a large network 987 if ( ! current_user_can( 'bp_moderate' ) || ( is_multisite() && wp_is_large_network( 'users' ) ) ) 987 if ( ! current_user_can( 'bp_moderate' ) || ( is_multisite() && wp_is_large_network( 'users' ) ) ) { 988 988 wp_die( -1 ); 989 } 990 991 $term = isset( $_GET['term'] ) ? sanitize_text_field( $_GET['term'] ) : ''; 992 $group_id = isset( $_GET['group_id'] ) ? absint( $_GET['group_id'] ) : 0; 989 993 990 $return = array(); 994 if ( ! $term || ! $group_id ) { 995 wp_die( -1 ); 996 } 991 997 992 // Exclude current group members 993 $group_id = isset( $_GET['group_id'] ) ? wp_parse_id_list( $_GET['group_id'] ) : array(); 994 $group_member_query = new BP_Group_Member_Query( array( 995 'group_id' => $group_id, 996 'per_page' => 0, // show all 997 'group_role' => array( 'member', 'mod', 'admin', ), 998 'populate_extras' => false, 999 'count_total' => false, 998 $suggestions = bp_core_get_suggestions( array( 999 'group_id' => -$group_id, // A negative value will exclude this group's members from the suggestions. 1000 'limit' => 10, 1001 'term' => $term, 1002 'type' => 'members', 1000 1003 ) ); 1001 1004 1002 $ group_members = ! empty( $group_member_query->results ) ? wp_list_pluck( $group_member_query->results, 'ID' ) :array();1005 $matches = array(); 1003 1006 1004 $terms = isset( $_GET['term'] ) ? $_GET['term'] : ''; 1005 $users = bp_core_get_users( array( 1006 'type' => 'alphabetical', 1007 'search_terms' => $terms, 1008 'exclude' => $group_members, 1009 'per_page' => 10, 1010 'populate_extras' => false 1011 ) ); 1007 if ( $suggestions && ! is_wp_error( $suggestions ) ) { 1008 foreach ( $suggestions as $user ) { 1012 1009 1013 foreach ( (array) $users['users'] as $user ) {1014 $return[] = array(1015 /* translators: 1: user_login, 2: user_email */1016 'label' => sprintf( __( '%1$s (%2$s)', 'buddypress' ), bp_is_username_compatibility_mode() ? $user->user_login : $user->user_nicename, $user->user_email ),1017 'value' => $user->user_nicename,1018 );1010 $matches[] = array( 1011 // translators: 1: user_login, 2: user_email 1012 'label' => sprintf( __( '%1$s (%2$s)', 'buddypress' ), $user->name, $user->ID ), 1013 'value' => $user->ID, 1014 ); 1015 } 1019 1016 } 1020 1017 1021 wp_die( json_encode( $ return) );1018 wp_die( json_encode( $matches ) ); 1022 1019 } 1023 1020 add_action( 'wp_ajax_bp_group_admin_member_autocomplete', 'bp_groups_admin_autocomplete_handler' ); 1024 1021 -
src/bp-groups/bp-groups-classes.php
diff --git a/src/bp-groups/bp-groups-classes.php b/src/bp-groups/bp-groups-classes.php index 2290660..916cadf 100644
a b function bp_register_group_extension( $group_extension_class = '' ) { 4076 4076 add_action( "admin_init", array( &$extension, "_register" ) ); 4077 4077 ' ), 11 ); 4078 4078 } 4079 4080 /** 4081 * Adds support for user at-mentions (for users in a specific Group) to the Suggestions API. 4082 * 4083 * @since BuddyPress (2.1.0) 4084 */ 4085 class BP_Groups_Member_Suggestions extends BP_Members_Suggestions { 4086 4087 /** 4088 * Default arguments for this suggestions service. 4089 * 4090 * @since BuddyPress (2.1.0) 4091 * @var array $args { 4092 * @type int $group_id Positive integers will restrict the search to members in that group. 4093 * Negative integers will restrict the search to members in every other group. 4094 * @type int $limit Maximum number of results to display. Default: 16. 4095 * @type bool $only_friends If true, only match the current user's friends. Default: false. 4096 * @type string $term The suggestion service will try to find results that contain this string. 4097 * Mandatory. 4098 * } 4099 */ 4100 protected $default_args = array( 4101 'group_id' => 0, 4102 'limit' => 16, 4103 'only_friends' => false, 4104 'term' => '', 4105 'type' => '', 4106 ); 4107 4108 4109 /** 4110 * Validate and sanitise the parameters for the suggestion service query. 4111 * 4112 * @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool). 4113 * @since BuddyPress (2.1.0) 4114 */ 4115 public function validate() { 4116 $this->args['group_id'] = (int) $this->args['group_id']; 4117 $this->args = apply_filters( 'bp_groups_member_suggestions_args', $this->args, $this ); 4118 4119 // Check for invalid or missing mandatory parameters. 4120 if ( ! $this->args['group_id'] || ! bp_is_active( 'groups' ) ) { 4121 return new WP_Error( 'missing_requirement' ); 4122 } 4123 4124 // Check that the specified group_id exists, and that the current user can access it. 4125 $the_group = groups_get_group( array( 4126 'group_id' => absint( $this->args['group_id'] ), 4127 'populate_extras' => true, 4128 ) ); 4129 4130 if ( $the_group->id === 0 || ! $the_group->user_has_access ) { 4131 return new WP_Error( 'access_denied' ); 4132 } 4133 4134 return apply_filters( 'bp_groups_member_suggestions_validate_args', parent::validate(), $this ); 4135 } 4136 4137 /** 4138 * Find and return a list of username suggestions that match the query. 4139 * 4140 * @return array|WP_Error Array of results. If there were problems, returns a WP_Error object. 4141 * @since BuddyPress (2.1.0) 4142 */ 4143 public function get_suggestions() { 4144 $user_query = array( 4145 'count_total' => '', // Prevents total count 4146 'populate_extras' => false, 4147 'type' => 'alphabetical', 4148 4149 'group_role' => array( 'admin', 'member', 'mod' ), 4150 'page' => 1, 4151 'per_page' => $this->args['limit'], 4152 'search_terms' => $this->args['term'], 4153 ); 4154 4155 // Only return matches of friends of this user. 4156 if ( $this->args['only_friends'] && is_user_logged_in() ) { 4157 $user_query['user_id'] = get_current_user_id(); 4158 } 4159 4160 // Positive Group IDs will restrict the search to members in that group. 4161 if ( $this->args['group_id'] > 0 ) { 4162 $user_query['group_id'] = $this->args['group_id']; 4163 4164 // Negative Group IDs will restrict the search to members in every other group. 4165 } else { 4166 $group_query = array( 4167 'count_total' => '', // Prevents total count 4168 'populate_extras' => false, 4169 'type' => 'alphabetical', 4170 4171 'group_id' => absint( $this->args['group_id'] ), 4172 'group_role' => array( 'admin', 'member', 'mod' ), 4173 'page' => 1, 4174 ); 4175 $group_users = new BP_Group_Member_Query( $group_query ); 4176 4177 if ( $group_users->results ) { 4178 $user_query['exclude'] = wp_list_pluck( $group_users->results, 'ID' ); 4179 } else { 4180 $user_query['include'] = array( 0 ); 4181 } 4182 } 4183 4184 $user_query = apply_filters( 'bp_groups_member_suggestions_query_args', $user_query, $this ); 4185 if ( is_wp_error( $user_query ) ) { 4186 return $user_query; 4187 } 4188 4189 4190 if ( isset( $user_query['group_id'] ) ) { 4191 $user_query = new BP_Group_Member_Query( $user_query ); 4192 } else { 4193 $user_query = new BP_User_Query( $user_query ); 4194 } 4195 4196 $results = array(); 4197 foreach ( $user_query->results as $user ) { 4198 $result = new stdClass(); 4199 $result->ID = $user->user_nicename; 4200 $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) ); 4201 $result->name = bp_core_get_user_displayname( $user->ID ); 4202 4203 $results[] = $result; 4204 } 4205 4206 return apply_filters( 'bp_groups_member_suggestions_get_suggestions', $results, $this ); 4207 } 4208 } 4209 No newline at end of file -
src/bp-templates/bp-legacy/buddypress-functions.php
diff --git a/src/bp-templates/bp-legacy/buddypress-functions.php b/src/bp-templates/bp-legacy/buddypress-functions.php index 784b2dc..455b60e 100644
a b function bp_legacy_theme_ajax_messages_delete() { 1383 1383 * @return string HTML. 1384 1384 */ 1385 1385 function bp_legacy_theme_ajax_messages_autocomplete_results() { 1386 1386 $limit = isset( $_GET['limit'] ) ? absint( $_GET['limit'] ) : (int) apply_filters( 'bp_autocomplete_max_results', 10 ); 1387 $term = isset( $_GET['q'] ) ? sanitize_text_field( $_GET['q'] ) : ''; 1388 1387 1389 // Include everyone in the autocomplete, or just friends? 1388 if ( bp_is_current_component( bp_get_messages_slug() ) ) 1389 $autocomplete_all = buddypress()->messages->autocomplete_all; 1390 1391 $pag_page = 1; 1392 $limit = (int) $_GET['limit'] ? $_GET['limit'] : apply_filters( 'bp_autocomplete_max_results', 10 ); 1393 $search_terms = isset( $_GET['q'] ) ? $_GET['q'] : ''; 1394 1395 $user_query_args = array( 1396 'search_terms' => $search_terms, 1397 'page' => intval( $pag_page ), 1398 'per_page' => intval( $limit ), 1399 ); 1400 1401 // If only matching against friends, get an $include param for 1402 // BP_User_Query 1403 if ( ! $autocomplete_all && bp_is_active( 'friends' ) ) { 1404 $include = BP_Friends_Friendship::get_friend_user_ids( bp_loggedin_user_id() ); 1405 1406 // Ensure zero matches if no friends are found 1407 if ( empty( $include ) ) { 1408 $include = array( 0 ); 1409 } 1410 1411 $user_query_args['include'] = $include; 1390 if ( bp_is_current_component( bp_get_messages_slug() ) ) { 1391 $only_friends = ( buddypress()->messages->autocomplete_all === false ); 1392 } else { 1393 $only_friends = true; 1412 1394 } 1413 1395 1414 $user_query = new BP_User_Query( $user_query_args ); 1415 1416 // Backward compatibility - if a plugin is expecting a legacy 1417 // filter, pass the IDs through the filter and requery (groan) 1418 if ( has_filter( 'bp_core_autocomplete_ids' ) || has_filter( 'bp_friends_autocomplete_ids' ) ) { 1419 $found_user_ids = wp_list_pluck( $user_query->results, 'ID' ); 1420 1421 if ( $autocomplete_all ) { 1422 $found_user_ids = apply_filters( 'bp_core_autocomplete_ids', $found_user_ids ); 1423 } else { 1424 $found_user_ids = apply_filters( 'bp_friends_autocomplete_ids', $found_user_ids ); 1425 } 1426 1427 if ( empty( $found_user_ids ) ) { 1428 $found_user_ids = array( 0 ); 1429 } 1430 1431 // Repopulate the $user_query variable 1432 $user_query = new BP_User_Query( array( 1433 'include' => $found_user_ids, 1434 ) ); 1435 } 1396 $suggestions = bp_core_get_suggestions( array( 1397 'limit' => $limit, 1398 'only_friends' => $only_friends, 1399 'term' => $term, 1400 'type' => 'members', 1401 ) ); 1436 1402 1437 if ( ! empty( $user_query->results ) ) { 1438 foreach ( $user_query->results as $user ) { 1439 if ( bp_is_username_compatibility_mode() ) { 1440 // Sanitize for spaces. Use urlencode() rather 1441 // than rawurlencode() because %20 breaks JS 1442 $username = urlencode( $user->user_login ); 1443 } else { 1444 $username = $user->user_nicename; 1445 } 1403 if ( $suggestions && ! is_wp_error( $suggestions ) ) { 1404 foreach ( $suggestions as $user ) { 1446 1405 1447 1406 // Note that the final line break acts as a delimiter for the 1448 1407 // autocomplete javascript and thus should not be removed 1449 echo '<span id="link-' . esc_attr( $username ) . '" href="' . bp_core_get_user_domain( $user->ID ) . '"></span>' . bp_core_fetch_avatar( array( 'item_id' => $user->ID, 'type' => 'thumb', 'width' => 15, 'height' => 15, 'alt' => $user->display_name ) ) . ' ' . bp_core_get_user_displayname( $user->ID ) . ' (' . esc_html( $username ) . ')' . "\n"; 1408 printf( '<span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s (%s)' . "\n", 1409 esc_attr( 'link-' . $user->ID ), 1410 esc_url( $user->image ), 1411 esc_html( $user->name ), 1412 esc_html( $user->ID ) 1413 ); 1450 1414 } 1451 1415 } 1452 1416 -
new file tests/phpunit/testcases/apis/suggestions-nonauth.php
diff --git a/tests/phpunit/testcases/apis/suggestions-nonauth.php b/tests/phpunit/testcases/apis/suggestions-nonauth.php new file mode 100644 index 0000000..a16fb8e
- + 1 <?php 2 /** 3 * Suggestions API tests specifically for non-authenticated (anonymous) users. 4 * 5 * @group api 6 * @group suggestions 7 */ 8 class BP_Tests_Suggestions_Non_Authenticated extends BP_UnitTestCase { 9 protected $group_ids = array(); 10 protected $group_slugs = array(); 11 protected $user_ids = array(); 12 13 public function setUp() { 14 parent::setUp(); 15 16 $users = array( 17 // user_login, display_name 18 array( 'aardvark', 'Bob Smith' ), 19 array( 'alpaca red', 'William Quinn' ), 20 array( 'cat', 'Lauren Curtis' ), 21 array( 'caterpillar', 'Eldon Burrows' ), 22 array( 'dog green', 'Reece Thornton' ), 23 array( 'pig', 'Joshua Barton' ), 24 array( 'rabbit blue', 'Amber Hooper' ), 25 array( 'smith', 'Robert Bar' ), 26 array( 'snake', 'Eleanor Moore' ), 27 array( 'xylo', 'Silver McFadden' ), 28 array( 'zoom', 'Lisa Smithy' ), 29 ); 30 31 // Create some dummy users. 32 foreach( $users as $user ) { 33 $this->user_ids[ $user[0] ] = $this->create_user( array( 34 'display_name' => $user[1], 35 'user_login' => $user[0], 36 ) ); 37 } 38 39 $this->group_slugs['hidden'] = 'the-maw'; 40 $this->group_slugs['public'] = 'the-great-journey'; 41 $this->group_slugs['private'] = 'tsavo-highway'; 42 43 // Create dummy groups. 44 $this->group_ids['hidden'] = $this->factory->group->create( array( 45 'creator_id' => $this->user_ids['xylo'], 46 'slug' => $this->group_slugs['hidden'], 47 'status' => 'hidden', 48 ) ); 49 $this->group_ids['public'] = $this->factory->group->create( array( 50 'creator_id' => $this->user_ids['xylo'], 51 'slug' => $this->group_slugs['public'], 52 'status' => 'public', 53 ) ); 54 $this->group_ids['private'] = $this->factory->group->create( array( 55 'creator_id' => $this->user_ids['xylo'], 56 'slug' => $this->group_slugs['private'], 57 'status' => 'private', 58 ) ); 59 60 // Add dummy users to dummy hidden groups. 61 groups_join_group( $this->group_ids['hidden'], $this->user_ids['pig'] ); 62 groups_join_group( $this->group_ids['hidden'], $this->user_ids['alpaca red'] ); 63 64 // Add dummy users to dummy public groups. 65 groups_join_group( $this->group_ids['public'], $this->user_ids['aardvark'] ); 66 groups_join_group( $this->group_ids['public'], $this->user_ids['alpaca red'] ); 67 groups_join_group( $this->group_ids['public'], $this->user_ids['cat'] ); 68 groups_join_group( $this->group_ids['public'], $this->user_ids['smith'] ); 69 70 // Add dummy users to dummy private groups. 71 groups_join_group( $this->group_ids['private'], $this->user_ids['cat'] ); 72 groups_join_group( $this->group_ids['private'], $this->user_ids['caterpillar'] ); 73 } 74 75 76 /** 77 * Tests below this point are expected to fail. 78 */ 79 80 public function test_suggestions_with_type_members_and_only_friends() { 81 // only_friends requires authenticated requests 82 $suggestions = bp_core_get_suggestions( array( 83 'only_friends' => true, 84 'type' => 'members', 85 'term' => 'smith', 86 ) ); 87 88 $this->assertTrue( is_wp_error( $suggestions ) ); 89 } 90 91 public function test_suggestions_with_type_groupmembers_and_only_friends() { 92 // only_friends requires authenticated requests 93 $suggestions = bp_core_get_suggestions( array( 94 'group_id' => $this->group_ids['public'], 95 'only_friends' => true, 96 'type' => 'members', 97 'term' => 'smith', 98 ) ); 99 100 $this->assertTrue( is_wp_error( $suggestions ) ); 101 } 102 103 public function test_suggestions_with_type_groupmembers_hidden() { 104 $suggestions = bp_core_get_suggestions( array( 105 'group_id' => $this->group_ids['hidden'], 106 'type' => 'members', 107 'term' => 'pig', 108 ) ); 109 110 $this->assertTrue( is_wp_error( $suggestions ) ); 111 } 112 113 public function test_suggestions_with_type_groupmembers_private() { 114 $suggestions = bp_core_get_suggestions( array( 115 'group_id' => $this->group_ids['private'], 116 'type' => 'members', 117 'term' => 'cat', 118 ) ); 119 120 $this->assertTrue( is_wp_error( $suggestions ) ); 121 } 122 123 public function test_suggestions_with_type_groupmembers_public_and_exclude_group_from_results() { 124 $suggestions = bp_core_get_suggestions( array( 125 'group_id' => $this->group_ids['public'], 126 'type' => 'members', 127 'term' => 'smith', 128 ) ); 129 $this->assertFalse( is_wp_error( $suggestions ) ); 130 $this->assertEquals( 2, count( $suggestions ) ); // aardvark, smith. 131 132 $suggestions = bp_core_get_suggestions( array( 133 'group_id' => -$this->group_ids['public'], 134 'type' => 'members', 135 'term' => 'smith', 136 ) ); 137 $this->assertFalse( is_wp_error( $suggestions ) ); 138 $this->assertEquals( 1, count( $suggestions ) ); // zoom 139 } 140 141 public function test_suggestions_with_type_groupmembers_private_and_exclude_group_from_results() { 142 $suggestions = bp_core_get_suggestions( array( 143 'group_id' => -$this->group_ids['private'], 144 'type' => 'members', 145 'term' => 'cat', 146 ) ); 147 $this->assertTrue( is_wp_error( $suggestions ) ); // no access to group. 148 } 149 150 public function test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results() { 151 $suggestions = bp_core_get_suggestions( array( 152 'group_id' => $this->group_ids['hidden'], 153 'type' => 'members', 154 'term' => 'pig', 155 ) ); 156 $this->assertTrue( is_wp_error( $suggestions ) ); // no access to group. 157 } 158 } 159 No newline at end of file -
new file tests/phpunit/testcases/apis/suggestions.php
diff --git a/tests/phpunit/testcases/apis/suggestions.php b/tests/phpunit/testcases/apis/suggestions.php new file mode 100644 index 0000000..c551a33
- + 1 <?php 2 /** 3 * Suggestions API tests for authenticated (logged in) users. 4 * 5 * @group api 6 * @group suggestions 7 */ 8 class BP_Tests_Suggestions_Authenticated extends BP_UnitTestCase { 9 protected $current_user = null; 10 protected $group_ids = array(); 11 protected $group_slugs = array(); 12 protected $old_user_id = 0; 13 protected $user_ids = array(); 14 15 public function setUp() { 16 parent::setUp(); 17 18 $this->old_user_id = get_current_user_id(); 19 $this->current_user = $this->create_user( array( 20 'display_name' => 'Katie Parker', 21 'user_login' => 'admin', 22 ) ); 23 24 $this->set_current_user( $this->current_user ); 25 26 $users = array( 27 // user_login, display_name 28 array( 'aardvark', 'Bob Smith' ), 29 array( 'alpaca red', 'William Quinn' ), 30 array( 'cat', 'Lauren Curtis' ), 31 array( 'caterpillar', 'Eldon Burrows' ), 32 array( 'dog green', 'Reece Thornton' ), 33 array( 'pig', 'Joshua Barton' ), 34 array( 'rabbit blue', 'Amber Hooper' ), 35 array( 'smith', 'Robert Bar' ), 36 array( 'snake', 'Eleanor Moore' ), 37 array( 'xylo', 'Silver McFadden' ), 38 array( 'zoom', 'Lisa Smithy' ), 39 ); 40 41 // Create some dummy users. 42 foreach ( $users as $user ) { 43 $this->user_ids[ $user[0] ] = $this->create_user( array( 44 'display_name' => $user[1], 45 'user_login' => $user[0], 46 ) ); 47 } 48 49 // Create some dummy friendships. 50 friends_add_friend( $this->current_user, $this->user_ids['aardvark'], true ); 51 friends_add_friend( $this->current_user, $this->user_ids['cat'], true ); 52 friends_add_friend( $this->current_user, $this->user_ids['caterpillar'], true ); 53 friends_add_friend( $this->current_user, $this->user_ids['pig'], true ); 54 55 $this->group_slugs['hidden'] = 'the-maw'; 56 $this->group_slugs['public'] = 'the-great-journey'; 57 $this->group_slugs['private'] = 'tsavo-highway'; 58 59 // Create dummy groups. 60 $this->group_ids['hidden'] = $this->factory->group->create( array( 61 'creator_id' => $this->user_ids['xylo'], 62 'slug' => $this->group_slugs['hidden'], 63 'status' => 'hidden', 64 ) ); 65 $this->group_ids['public'] = $this->factory->group->create( array( 66 'creator_id' => $this->user_ids['xylo'], 67 'slug' => $this->group_slugs['public'], 68 'status' => 'public', 69 ) ); 70 $this->group_ids['private'] = $this->factory->group->create( array( 71 'creator_id' => $this->user_ids['xylo'], 72 'slug' => $this->group_slugs['private'], 73 'status' => 'private', 74 ) ); 75 76 // Add dummy users to dummy hidden groups. 77 groups_join_group( $this->group_ids['hidden'], $this->user_ids['pig'] ); 78 groups_join_group( $this->group_ids['hidden'], $this->user_ids['alpaca red'] ); 79 80 // Add dummy users to dummy public groups. 81 groups_join_group( $this->group_ids['public'], $this->current_user ); 82 groups_join_group( $this->group_ids['public'], $this->user_ids['aardvark'] ); 83 groups_join_group( $this->group_ids['public'], $this->user_ids['alpaca red'] ); 84 groups_join_group( $this->group_ids['public'], $this->user_ids['cat'] ); 85 groups_join_group( $this->group_ids['public'], $this->user_ids['smith'] ); 86 87 // Add dummy users to dummy private groups. 88 groups_join_group( $this->group_ids['private'], $this->user_ids['cat'] ); 89 groups_join_group( $this->group_ids['private'], $this->user_ids['caterpillar'] ); 90 } 91 92 public function tearDown() { 93 parent::tearDown(); 94 $this->set_current_user( $this->old_user_id ); 95 } 96 97 98 public function test_suggestions_with_type_members() { 99 $suggestions = bp_core_get_suggestions( array( 100 'type' => 'members', 101 'term' => 'smith', 102 ) ); 103 104 $this->assertFalse( is_wp_error( $suggestions ) ); 105 $this->assertEquals( 3, count( $suggestions ) ); // aardvark, smith, zoom. 106 } 107 108 public function test_suggestions_with_type_members_and_limit() { 109 $suggestions = bp_core_get_suggestions( array( 110 'limit' => 2, 111 'type' => 'members', 112 'term' => 'smith', 113 ) ); 114 115 $this->assertFalse( is_wp_error( $suggestions ) ); 116 $this->assertEquals( 2, count( $suggestions ) ); // two of: aardvark, smith, zoom. 117 } 118 119 public function test_suggestions_with_type_members_and_only_friends() { 120 $suggestions = bp_core_get_suggestions( array( 121 'only_friends' => true, 122 'type' => 'members', 123 'term' => 'smith', 124 ) ); 125 $this->assertFalse( is_wp_error( $suggestions ) ); 126 $this->assertEquals( 1, count( $suggestions ) ); // aardvark. 127 128 $suggestions = bp_core_get_suggestions( array( 129 'only_friends' => true, 130 'type' => 'members', 131 'term' => 'cat', 132 ) ); 133 $this->assertFalse( is_wp_error( $suggestions ) ); 134 $this->assertEquals( 2, count( $suggestions ) ); // cat, caterpillar. 135 } 136 137 public function test_suggestions_with_type_members_and_term_as_displayname() { 138 $suggestions = bp_core_get_suggestions( array( 139 'type' => 'members', 140 'term' => 'aardvark', 141 ) ); 142 143 $this->assertFalse( is_wp_error( $suggestions ) ); 144 $this->assertEquals( 1, count( $suggestions ) ); // aardvark. 145 } 146 147 public function test_suggestions_with_type_members_and_term_as_usernicename() { 148 $suggestions = bp_core_get_suggestions( array( 149 'type' => 'members', 150 'term' => 'eleanor', 151 ) ); 152 153 $this->assertFalse( is_wp_error( $suggestions ) ); 154 $this->assertEquals( 1, count( $suggestions ) ); // snake. 155 } 156 157 public function test_suggestions_with_term_as_current_user() { 158 $suggestions = bp_core_get_suggestions( array( 159 'type' => 'members', 160 'term' => 'katie', 161 ) ); 162 163 $this->assertFalse( is_wp_error( $suggestions ) ); 164 $this->assertEquals( 1, count( $suggestions ) ); 165 $this->assertSame( 'admin', $suggestions[0]->ID ); 166 } 167 168 169 public function test_suggestions_with_type_groupmembers_public() { 170 $suggestions = bp_core_get_suggestions( array( 171 'group_id' => $this->group_ids['public'], 172 'type' => 'members', 173 'term' => 'smith', 174 ) ); 175 176 $this->assertFalse( is_wp_error( $suggestions ) ); 177 $this->assertEquals( 2, count( $suggestions ) ); // aardvark, smith. 178 } 179 180 public function test_suggestions_with_type_groupmembers_public_and_limit() { 181 $suggestions = bp_core_get_suggestions( array( 182 'limit' => 1, 183 'group_id' => $this->group_ids['public'], 184 'type' => 'members', 185 'term' => 'smith', 186 ) ); 187 188 $this->assertFalse( is_wp_error( $suggestions ) ); 189 $this->assertEquals( 1, count( $suggestions ) ); // one of: aardvark, smith. 190 } 191 192 public function test_suggestions_with_type_groupmembers_public_and_only_friends() { 193 $suggestions = bp_core_get_suggestions( array( 194 'group_id' => $this->group_ids['public'], 195 'only_friends' => true, 196 'type' => 'members', 197 'term' => 'smith', 198 ) ); 199 200 $this->assertFalse( is_wp_error( $suggestions ) ); 201 $this->assertEquals( 1, count( $suggestions ) ); // aardvark. 202 } 203 204 public function test_suggestions_with_type_groupmembers_public_and_term_as_displayname() { 205 $suggestions = bp_core_get_suggestions( array( 206 'group_id' => $this->group_ids['public'], 207 'type' => 'members', 208 'term' => 'aardvark', 209 ) ); 210 211 $this->assertFalse( is_wp_error( $suggestions ) ); 212 $this->assertEquals( 1, count( $suggestions ) ); // aardvark. 213 } 214 215 public function test_suggestions_with_type_groupmembers_public_and_term_as_usernicename() { 216 $suggestions = bp_core_get_suggestions( array( 217 'group_id' => $this->group_ids['public'], 218 'type' => 'members', 219 'term' => 'robert', 220 ) ); 221 222 $this->assertFalse( is_wp_error( $suggestions ) ); 223 $this->assertEquals( 1, count( $suggestions ) ); // smith. 224 } 225 226 public function test_suggestions_with_type_groupmembers_public_as_id() { 227 $suggestions = bp_core_get_suggestions( array( 228 'group_id' => $this->group_ids['public'], 229 'type' => 'members', 230 'term' => 'smith', 231 ) ); 232 233 $this->assertFalse( is_wp_error( $suggestions ) ); 234 $this->assertEquals( 2, count( $suggestions ) ); // aardvark, smith. 235 } 236 237 public function test_suggestions_with_type_groupmembers_hidden() { 238 // current_user isn't a member of the hidden group 239 $suggestions = bp_core_get_suggestions( array( 240 'group_id' => $this->group_ids['hidden'], 241 'type' => 'members', 242 'term' => 'pig', 243 ) ); 244 $this->assertTrue( is_wp_error( $suggestions ) ); 245 246 // "alpaca red" is in the hidden group 247 $this->set_current_user( $this->user_ids['alpaca red'] ); 248 $suggestions = bp_core_get_suggestions( array( 249 'group_id' => $this->group_ids['hidden'], 250 'type' => 'members', 251 'term' => 'pig', 252 ) ); 253 $this->assertFalse( is_wp_error( $suggestions ) ); 254 $this->assertEquals( 1, count( $suggestions ) ); // pig 255 } 256 257 public function test_suggestions_with_type_groupmembers_private() { 258 // current_user isn't a member of the private group. 259 $suggestions = bp_core_get_suggestions( array( 260 'group_id' => $this->group_ids['private'], 261 'type' => 'members', 262 'term' => 'cat', 263 ) ); 264 $this->assertTrue( is_wp_error( $suggestions ) ); 265 266 // "caterpillar" is in the private group 267 $this->set_current_user( $this->user_ids['caterpillar'] ); 268 $suggestions = bp_core_get_suggestions( array( 269 'group_id' => $this->group_ids['private'], 270 'type' => 'members', 271 'term' => 'cat', 272 ) ); 273 $this->assertFalse( is_wp_error( $suggestions ) ); 274 $this->assertEquals( 2, count( $suggestions ) ); // cat, caterpillar 275 } 276 277 278 public function test_suggestions_with_type_groupmembers_public_and_exclude_group_from_results() { 279 $suggestions = bp_core_get_suggestions( array( 280 'group_id' => $this->group_ids['public'], 281 'type' => 'members', 282 'term' => 'smith', 283 ) ); 284 $this->assertFalse( is_wp_error( $suggestions ) ); 285 $this->assertEquals( 2, count( $suggestions ) ); // aardvark, smith. 286 287 $suggestions = bp_core_get_suggestions( array( 288 'group_id' => -$this->group_ids['public'], 289 'type' => 'members', 290 'term' => 'smith', 291 ) ); 292 $this->assertFalse( is_wp_error( $suggestions ) ); 293 $this->assertEquals( 1, count( $suggestions ) ); // zoom 294 } 295 296 public function test_suggestions_with_type_groupmembers_private_and_exclude_group_from_results() { 297 // current_user isn't a member of the private group. 298 $suggestions = bp_core_get_suggestions( array( 299 'group_id' => -$this->group_ids['private'], 300 'type' => 'members', 301 'term' => 'cat', 302 ) ); 303 $this->assertTrue( is_wp_error( $suggestions ) ); 304 305 306 $this->set_current_user( $this->user_ids['caterpillar'] ); 307 308 // "cat" is in the private group, so won't show up here. 309 $suggestions = bp_core_get_suggestions( array( 310 'group_id' => -$this->group_ids['private'], 311 'type' => 'members', 312 'term' => 'cat', 313 ) ); 314 $this->assertFalse( is_wp_error( $suggestions ) ); 315 $this->assertEmpty( $suggestions ); 316 317 // "zoo" is not the private group, so will show up here. 318 $suggestions = bp_core_get_suggestions( array( 319 'group_id' => -$this->group_ids['private'], 320 'type' => 'members', 321 'term' => 'zoo', 322 ) ); 323 $this->assertFalse( is_wp_error( $suggestions ) ); 324 $this->assertEquals( 1, count( $suggestions ) ); // zoo 325 } 326 327 public function test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results() { 328 // current_user isn't a member of the hidden group. 329 $suggestions = bp_core_get_suggestions( array( 330 'group_id' => $this->group_ids['hidden'], 331 'type' => 'members', 332 'term' => 'pig', 333 ) ); 334 $this->assertTrue( is_wp_error( $suggestions ) ); 335 336 337 $this->set_current_user( $this->user_ids['alpaca red'] ); 338 339 // "alpaca red" is in the hidden group, so won't show up here. 340 $suggestions = bp_core_get_suggestions( array( 341 'group_id' => -$this->group_ids['hidden'], 342 'type' => 'members', 343 'term' => 'alpaca red', 344 ) ); 345 $this->assertFalse( is_wp_error( $suggestions ) ); 346 $this->assertEmpty( $suggestions ); 347 348 // "zoo" is not the hidden group, so will show up here. 349 $suggestions = bp_core_get_suggestions( array( 350 'group_id' => -$this->group_ids['hidden'], 351 'type' => 'members', 352 'term' => 'zoo', 353 ) ); 354 $this->assertFalse( is_wp_error( $suggestions ) ); 355 $this->assertEquals( 1, count( $suggestions ) ); // zoo 356 } 357 358 359 /** 360 * These next tests check the format of the response from the Suggestions API. 361 */ 362 363 public function test_suggestions_response_no_matches() { 364 $suggestions = bp_core_get_suggestions( array( 365 'term' => 'abcdefghijklmnopqrstuvwxyz', 366 'type' => 'members', 367 ) ); 368 369 $this->assertFalse( is_wp_error( $suggestions ) ); 370 $this->assertInternalType( 'array', $suggestions ); 371 $this->assertEmpty( $suggestions ); 372 } 373 374 public function test_suggestions_response_single_match() { 375 $suggestion = bp_core_get_suggestions( array( 376 'term' => 'zoom', 377 'type' => 'members', 378 ) ); 379 380 $this->assertFalse( is_wp_error( $suggestion ) ); 381 $this->assertInternalType( 'array', $suggestion ); 382 $this->assertNotEmpty( $suggestion ); 383 384 $suggestion = array_shift( $suggestion ); 385 386 $this->assertInternalType( 'object', $suggestion ); 387 $this->assertAttributeNotEmpty( 'image', $suggestion ); 388 $this->assertAttributeNotEmpty( 'ID', $suggestion ); 389 $this->assertAttributeNotEmpty( 'name', $suggestion ); 390 } 391 392 public function test_suggestions_response_multiple_matches() { 393 $suggestions = bp_core_get_suggestions( array( 394 'term' => 'cat', 395 'type' => 'members', 396 ) ); 397 398 $this->assertFalse( is_wp_error( $suggestions ) ); 399 $this->assertInternalType( 'array', $suggestions ); 400 $this->assertNotEmpty( $suggestions ); 401 402 foreach ( $suggestions as $suggestion ) { 403 $this->assertInternalType( 'object', $suggestion ); 404 $this->assertAttributeNotEmpty( 'image', $suggestion ); 405 $this->assertAttributeNotEmpty( 'ID', $suggestion ); 406 $this->assertAttributeNotEmpty( 'name', $suggestion ); 407 } 408 } 409 410 public function test_suggestions_term_is_case_insensitive() { 411 $lowercase = bp_core_get_suggestions( array( 412 'term' => 'lisa', 413 'type' => 'members', 414 ) ); 415 $this->assertFalse( is_wp_error( $lowercase ) ); 416 $this->assertEquals( 1, count( $lowercase ) ); 417 418 $uppercase = bp_core_get_suggestions( array( 419 'term' => 'LISA', 420 'type' => 'members', 421 ) ); 422 $this->assertFalse( is_wp_error( $uppercase ) ); 423 $this->assertEquals( 1, count( $uppercase ) ); 424 425 $this->assertSame( $lowercase[0]->ID, $uppercase[0]->ID ); 426 $this->assertSame( 'zoom', $lowercase[0]->ID ); 427 } 428 429 public function test_suggestions_response_property_types() { 430 $suggestion = bp_core_get_suggestions( array( 431 'term' => 'zoom', 432 'type' => 'members', 433 ) ); 434 435 $this->assertFalse( is_wp_error( $suggestion ) ); 436 $this->assertInternalType( 'array', $suggestion ); 437 $this->assertNotEmpty( $suggestion ); 438 439 $suggestion = array_shift( $suggestion ); 440 441 $this->assertInternalType( 'object', $suggestion ); 442 $this->assertAttributeInternalType( 'string', 'image', $suggestion ); 443 $this->assertAttributeInternalType( 'string', 'ID', $suggestion ); 444 $this->assertAttributeInternalType( 'string', 'name', $suggestion ); 445 } 446 447 448 /** 449 * Tests below this point are expected to fail. 450 */ 451 452 public function test_suggestions_with_bad_type() { 453 $suggestions = bp_core_get_suggestions( array( 454 'type' => 'fake_type', 455 ) ); 456 457 $this->assertTrue( is_wp_error( $suggestions ) ); 458 } 459 460 public function test_suggestions_with_type_groupmembers_and_bad_group_ids() { 461 // group_ids can't be a group slug. 462 $suggestions = bp_core_get_suggestions( array( 463 'group_id' => 'fake-group-slug', 464 'type' => 'members', 465 ) ); 466 467 $this->assertTrue( is_wp_error( $suggestions ) ); 468 } 469 470 public function test_suggestions_with_bad_term() { 471 // a non-empty term is mandatory 472 $suggestions = bp_core_get_suggestions( array( 473 'term' => '', 474 'type' => 'members', 475 ) ); 476 477 $this->assertTrue( is_wp_error( $suggestions ) ); 478 } 479 } 480 No newline at end of file