Changeset 14026
- Timestamp:
- 09/27/2024 09:11:27 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 66 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.wp-env.json
r13684 r14026 1 1 { 2 2 "core": "WordPress/WordPress#master", 3 "plugins": ["." , "buddypress/BP-REST#master"],3 "plugins": ["."], 4 4 "config": { 5 5 "WP_DEBUG": true, -
trunk/Gruntfile.js
r13850 r14026 76 76 * 77 77 * @param {String} filepath 78 * @returns {Bool }78 * @returns {Boolean} 79 79 */ 80 80 filter: function( filepath ) { … … 91 91 92 92 // Match only the filename passed from cli 93 if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) { 94 return true; 95 } 96 97 return false; 93 return filepath === file || (-1 !== index && index === filepath.length - (file.length + 1)); 98 94 } 99 95 } … … 199 195 clean: { 200 196 all: [ BUILD_DIR ], 201 bp_rest: [ BUILD_DIR + 'bp-rest/' ],202 197 bp_admin_modern_js: [ 'dist/' ], 203 198 cli: [ … … 225 220 ] 226 221 }, 227 bp_rest_components: {228 cwd: BUILD_DIR + 'bp-rest/includes/',229 dest: BUILD_DIR,230 dot: true,231 expand: true,232 src: ['**/bp-activity/**', '**/bp-blogs/**', '**/bp-friends/**', '**/bp-groups/**', '**/bp-members/**', '**/bp-messages/**', '**/bp-notifications/**', '**/bp-settings/**', '**/bp-xprofile/**'],233 options: {234 process : function( content ) {235 return content.replace( /\@since 0\.1\.0/g, '@since 5.0.0' );236 }237 }238 },239 bp_rest_core: {240 cwd: BUILD_DIR + 'bp-rest/includes/',241 dest: BUILD_DIR + 'bp-core/classes/',242 dot: true,243 expand: true,244 flatten: true,245 filter: 'isFile',246 src: ['**', '!functions.php', '!**/bp-activity/**', '!**/bp-blogs/**', '!**/bp-friends/**', '!**/bp-groups/**', '!**/bp-members/**', '!**/bp-messages/**', '!**/bp-notifications/**', '!**/bp-settings/**', '!**/bp-xprofile/**'],247 options: {248 process : function( content ) {249 return content.replace( /\@since 0\.1\.0/g, '@since 5.0.0' );250 }251 }252 },253 222 bp_admin_modern_js: { 254 223 cwd: 'dist/', … … 351 320 command: 'composer run phpcompat', 352 321 stdout: true 353 },354 rest_api: {355 command: 'npm run download:rest',356 cwd: BUILD_DIR,357 stdout: false358 322 }, 359 323 makepot: { … … 409 373 grunt.registerTask( 'commit', ['src', 'checktextdomain', 'imagemin', 'phplint', 'exec:phpcs_escape', 'exec:phpcompat'] ); 410 374 grunt.registerTask( 'commit:blocks', ['commit', 'exec:blocks_src', 'exec:modernJS_src'] ); 411 grunt.registerTask( 'bp_rest', [ 'exec:rest_api', 'copy:bp_rest_components', 'copy:bp_rest_core', 'clean:bp_rest' ] ); 412 grunt.registerTask( 'build', ['commit:blocks', 'clean:all', 'copy:files', 'uglify:core', 'jsvalidate:build', 'cssmin', 'bp_rest', 'makepot', 'exec:cli', 'clean:cli'] ); 375 grunt.registerTask( 'build', ['commit:blocks', 'clean:all', 'copy:files', 'uglify:core', 'jsvalidate:build', 'cssmin', 'makepot', 'exec:cli', 'clean:cli'] ); 413 376 grunt.registerTask( 'release', ['build'] ); 414 377 grunt.registerTask( 'move:admin:js', [ 'copy:bp_admin_modern_js', 'clean:bp_admin_modern_js' ] ); -
trunk/docs/contributor/code/README.md
r13769 r14026 111 111 ``` 112 112 113 You should see that your `~/Plugins/buddypress` directory now contains 1 or 2 more sub 113 You should see that your `~/Plugins/buddypress` directory now contains 1 or 2 more subdirectories: `/node_modules` and `/vendor` if you installed the composer packages. 114 114 115 115  … … 121 121 ``` 122 122 123 The first time you’ll execute this command it will take some time to run and you’ll see that 2 downloads will start: 124 125 - [BP REST](https://github.com/buddypress/BP-REST): it’s the plugin we use to develop the BP REST API. 123 The first time you’ll execute this command it will take some time to run, and you’ll see that the following download will start: 124 126 125 - [WordPress](https://core.trac.wordpress.org/browser/trunk): it’s the WordPress development version. 127 126 … … 176 175 ### Customizing your BuddyPress local development environment 177 176 178 To develop BuddyPress we use the development version of [WordPress](https://core.trac.wordpress.org/browser/trunk), the development version of the [BP REST API](https://github.com/buddypress/BP-REST)and we set two debugging constants:177 To develop BuddyPress we use the development version of [WordPress](https://core.trac.wordpress.org/browser/trunk), and we set two debugging constants: 179 178 180 179 ```php … … 190 189 { 191 190 "core": "WordPress/WordPress#master", 192 "plugins": [ ".", "buddypress/ BP-REST#master", "buddypress/bp-classic#trunk" ],191 "plugins": [ ".", "buddypress/bp-classic#trunk" ], 193 192 "config": { 194 193 "WP_DEBUG": true, … … 206 205 ## Patching BuddyPress 207 206 208 Let’s work with a real bug example (It might ha sbeen fixed when you’ll read this page!) to understand how to suggest a fix to the BuddyPress development team. First, open the `~/Plugins/buddypress` directory into your favorite code editor.207 Let’s work with a real bug example (It might have been fixed when you’ll read this page!) to understand how to suggest a fix to the BuddyPress development team. First, open the `~/Plugins/buddypress` directory into your favorite code editor. 209 208 210 209  -
trunk/package.json
r13953 r14026 56 56 "test-php-multisite": "npm run wp-env run cli -- --env-cwd=wp-content/plugins/buddypress composer test_multi", 57 57 "test-php-multisite:group": "npm run wp-env run cli -- --env-cwd=wp-content/plugins/buddypress composer test_multi -- -- --group ", 58 "download:cli": "curl -L -o 'cli-archive.zip' https://github.com/buddypress/wp-cli-buddypress/archive/3.0.1.zip && unzip -qq cli-archive.zip && mv wp-cli-buddypress-3.0.1 build/cli && rm cli-archive.zip", 59 "download:rest": "curl -L -o 'rest-archive.zip' https://github.com/buddypress/BP-REST/archive/master.zip && unzip -qq rest-archive.zip && mv BP-REST-master build/bp-rest && rm rest-archive.zip" 58 "download:cli": "curl -L -o 'cli-archive.zip' https://github.com/buddypress/wp-cli-buddypress/archive/3.0.1.zip && unzip -qq cli-archive.zip && mv wp-cli-buddypress-3.0.1 build/cli && rm cli-archive.zip" 60 59 }, 61 60 "keywords": [ -
trunk/phpcs.xml.dist
r14016 r14026 63 63 <exclude name="WordPress.DB.DirectDatabaseQuery.SchemaChange" /> 64 64 <exclude name="WordPress.DB.DirectDatabaseQuery.DirectQuery" /> 65 66 65 </rule> 67 66 </ruleset> -
trunk/phpunit.xml.dist
r13859 r14026 10 10 <testsuite name="default"> 11 11 <directory suffix=".php">./tests/phpunit/testcases/</directory> 12 13 <exclude>./tests/phpunit/testcases/blogs/test-controller.php</exclude> 14 <exclude>./tests/phpunit/testcases/blogs/test-blog-avatar-controller.php</exclude> 12 15 </testsuite> 13 16 </testsuites> -
trunk/src/bp-activity/classes/class-bp-activity-component.php
r13689 r14026 33 33 array( 34 34 'adminbar_myaccount_order' => 10, 35 'search_query_arg' => 'activity_search',36 'features' => array( 'embeds' )35 'search_query_arg' => 'activity_search', 36 'features' => array( 'embeds' ), 37 37 ) 38 38 ); … … 152 152 153 153 if ( bp_is_active( 'friends' ) ) { 154 $filenames[ bp_get_friends_slug()] = 'friends';154 $filenames[ bp_get_friends_slug() ] = 'friends'; 155 155 } 156 156 157 157 if ( bp_is_active( 'groups' ) ) { 158 $filenames[ bp_get_groups_slug()] = 'groups';158 $filenames[ bp_get_groups_slug() ] = 'groups'; 159 159 } 160 160 … … 210 210 // Fetch the default directory title. 211 211 $default_directory_titles = bp_core_get_directory_page_default_titles(); 212 $default_directory_title = $default_directory_titles[ $this->id];212 $default_directory_title = $default_directory_titles[ $this->id ]; 213 213 214 214 // All globals for activity component. … … 231 231 'bp/latest-activities' => array( 232 232 'widget_classnames' => array( 'wp-block-bp-latest-activities', 'buddypress' ), 233 ) 233 ), 234 234 ), 235 235 ); … … 258 258 'screen_function' => 'bp_activity_screen_my_activity', 259 259 'default_subnav_slug' => 'just-me', 260 'item_css_id' => $this->id 260 'item_css_id' => $this->id, 261 261 ); 262 262 … … 267 267 'parent_slug' => $slug, 268 268 'screen_function' => 'bp_activity_screen_my_activity', 269 'position' => 10 269 'position' => 10, 270 270 ); 271 271 … … 312 312 'screen_function' => 'bp_activity_screen_groups', 313 313 'position' => 50, 314 'item_css_id' => 'activity-groups' 314 'item_css_id' => 'activity-groups', 315 315 ); 316 316 } … … 409 409 'title' => _x( 'Groups', 'My Account Activity sub nav', 'buddypress' ), 410 410 'href' => bp_loggedin_user_url( bp_members_get_path_chunks( array( $activity_slug, bp_get_groups_slug() ) ) ), 411 'position' => 50 411 'position' => 50, 412 412 ); 413 413 } … … 421 421 * 422 422 * @since 1.5.0 423 *424 423 */ 425 424 public function setup_title() { … … 432 431 $bp->bp_options_title = _x( 'My Activity', 'Page and <title>', 'buddypress' ); 433 432 } else { 434 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 435 'item_id' => bp_displayed_user_id(), 436 'type' => 'thumb', 437 'alt' => sprintf( 433 $bp->bp_options_avatar = bp_core_fetch_avatar( 434 array( 435 'item_id' => bp_displayed_user_id(), 436 'type' => 'thumb', 437 'alt' => sprintf( 438 438 /* translators: %s: member name */ 439 __( 'Profile picture of %s', 'buddypress' ), 440 bp_get_displayed_user_fullname() 441 ), 442 ) ); 439 __( 'Profile picture of %s', 'buddypress' ), 440 bp_get_displayed_user_fullname() 441 ), 442 ) 443 ); 443 444 $bp->bp_options_title = bp_get_displayed_user_fullname(); 444 445 } … … 456 457 457 458 // Global groups. 458 wp_cache_add_global_groups( array( 459 'bp_activity', 460 'bp_activity_comments', 461 'activity_meta' 462 ) ); 459 wp_cache_add_global_groups( 460 array( 461 'bp_activity', 462 'bp_activity_comments', 463 'activity_meta', 464 ) 465 ); 463 466 464 467 parent::setup_cache_groups(); … … 525 528 */ 526 529 public function rest_api_init( $controllers = array() ) { 527 parent::rest_api_init( array( 'BP_ REST_Activity_Endpoint' ) );530 parent::rest_api_init( array( 'BP_Activity_REST_Controller' ) ); 528 531 } 529 532 … … 548 551 $blocks['bp/embed-activity'] = array( 549 552 'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-activity/blocks/embed-activity', 550 551 553 ); 552 554 } -
trunk/src/bp-blogs/bp-blogs-filters.php
r13476 r14026 190 190 return $retval; 191 191 } 192 193 /** 194 * Filter the Blog url in the WP_REST_Request::from_url(). 195 * 196 * First part in embedding the latest blog post. 197 * 198 * @link https://github.com/buddypress/BP-REST/pull/395 199 * 200 * @param WP_REST_Request $request Request used to generate the response. 201 * @param string $url URL being requested. 202 * @return WP_REST_Request 203 */ 204 function bp_filter_rest_request_blog_url( $request, $url ) { 205 206 if ( ! bp_is_active( 'blogs' ) || empty( $url ) ) { 207 return $request; 208 } 209 210 // Get url info. 211 $bits = wp_parse_url( $url ); 212 $home_bits = wp_parse_url( get_home_url() ); 213 214 if ( empty( $bits['host'] ) || empty( $home_bits['host'] ) ) { 215 return $request; 216 } 217 218 // Bail early if the request URL is the same as the current site. 219 if ( $bits['host'] === $home_bits['host'] ) { 220 return $request; 221 } 222 223 // Create a fake request to bypass the current logic. 224 $request = new WP_REST_Request( 'GET', $bits['path'] ); 225 $request->set_query_params( array( 'bp_blogs_url' => $url ) ); 226 227 return $request; 228 } 229 add_filter( 'rest_request_from_url', 'bp_filter_rest_request_blog_url', 10, 2 ); 230 231 /** 232 * Output BuddyPress blog response. 233 * 234 * Second part in embedding the latest blog post. 235 * 236 * @link https://github.com/buddypress/BP-REST/pull/395 237 * 238 * @param WP_REST_Response $response Response generated by the request. 239 * @param WP_REST_Server $instance Server instance. 240 * @param WP_REST_Request $request Request used to generate the response. 241 * @return WP_REST_Response 242 */ 243 function bp_rest_post_dispatch( $response, $instance, $request ) { 244 if ( 245 ! bp_is_active( 'blogs' ) 246 || 404 !== $response->get_status() 247 || 'embed' !== $request->get_param( 'context' ) 248 || empty( $request->get_param( 'bp_blogs_url' ) ) 249 || empty( $request->get_route() ) 250 ) { 251 return $response; 252 } 253 254 // Get domain from url. 255 $bits = wp_parse_url( $request->get_param( 'bp_blogs_url' ) ); 256 257 // We need those two to proceed. 258 if ( empty( $bits['host'] ) || empty( $bits['path'] ) ) { 259 return $response; 260 } 261 262 // Request route and requested URL path should match. 263 if ( $request->get_route() !== $bits['path'] ) { 264 return $response; 265 } 266 267 // Get site using the domain. 268 $site = get_site_by_path( $bits['host'], $bits['path'] ); 269 270 if ( ! $site instanceof WP_Site || empty( $site->blog_id ) ) { 271 return $response; 272 } 273 274 switch_to_blog( absint( $site->blog_id ) ); 275 276 $response = rest_do_request( 277 new WP_REST_Request( 278 'GET', 279 str_replace( 280 '/wp-json', 281 '', 282 $request->get_route() 283 ) 284 ) 285 ); 286 287 restore_current_blog(); 288 289 // Return it, regardless if it was successful. 290 return $response; 291 } 292 add_filter( 'rest_post_dispatch', 'bp_rest_post_dispatch', 10, 3 ); -
trunk/src/bp-blogs/bp-blogs-template.php
r13970 r14026 374 374 $alt_attribute = __( 'Site icon for the blog', 'buddypress' ); 375 375 376 if ( ! $blogs_template && isset( $args['blog_id'] ) && $args['blog_id'] ) { 376 $has_current_blog = isset( $blogs_template ) && isset( $blogs_template->blog->blog_id ); 377 378 if ( false === $has_current_blog && isset( $args['blog_id'] ) && $args['blog_id'] ) { 377 379 $blog_id = (int) $args['blog_id']; 378 } else {380 } else if ( true === $has_current_blog ) { 379 381 $blog_id = bp_get_blog_id(); 380 382 381 383 /* translators: %s is the blog name */ 382 384 $alt_attribute = sprintf( __( 'Site icon for %s', 'buddypress' ), bp_get_blog_name() ); 385 } else { 386 $blog_id = 0; 383 387 } 384 388 -
trunk/src/bp-blogs/classes/class-bp-blogs-component.php
r14010 r14026 512 512 public function rest_api_init( $controllers = array() ) { 513 513 if ( is_multisite() ) { 514 $controllers = array( 'BP_ REST_Blogs_Endpoint' );514 $controllers = array( 'BP_Blogs_REST_Controller' ); 515 515 516 516 // Support to Blog Avatar. 517 517 if ( bp_is_active( 'blogs', 'site-icon' ) ) { 518 $controllers[] = 'BP_ REST_Attachments_Blog_Avatar_Endpoint';518 $controllers[] = 'BP_Blogs_Avatar_REST_Controller'; 519 519 } 520 520 } -
trunk/src/bp-blogs/classes/class-bp-blogs-recent-posts-widget.php
r13802 r14026 12 12 defined( 'ABSPATH' ) || exit; 13 13 14 _deprecated_file( basename( __FILE__ ), '12.0.0', '', esc_html__( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) ); 14 _deprecated_file( 15 basename( __FILE__ ), 16 '12.0.0', 17 '', 18 esc_html__( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) 19 ); 15 20 16 21 /** -
trunk/src/bp-core/bp-core-functions.php
r14013 r14026 5007 5007 /* 5008 5008 * If the constant is not defined, put our logic in place so that only the 5009 * 2 last versions deprecated functions will be loaded for upgraded install s.5009 * 2 last versions deprecated functions will be loaded for upgraded installations. 5010 5010 */ 5011 5011 $initial_version = (float) bp_get_initial_version(); … … 5013 5013 $load_latest_deprecated = $initial_version < $current_major_version; 5014 5014 5015 // New install s.5015 // New installations. 5016 5016 if ( ! $load_latest_deprecated ) { 5017 5017 // Run some additional checks if PHPUnit is running. … … 5019 5019 $deprecated_files = array_filter( 5020 5020 array_map( 5021 function ( $file ) {5022 if ( false !== strpos( $file, '.php' ) ) {5021 function ( $file ) { 5022 if ( str_contains( $file, '.php' ) ) { 5023 5023 return (float) str_replace( '.php', '', $file ); 5024 }; 5024 } 5025 5026 return null; 5025 5027 }, 5026 5028 scandir( buddypress()->plugin_dir . 'bp-core/deprecated' ) -
trunk/src/bp-core/bp-core-rest-api.php
r14013 r14026 12 12 13 13 /** 14 * Is the BP REST plugin isactive?14 * Is the BP REST plugin active? 15 15 * 16 16 * @since 5.0.0 … … 23 23 24 24 /** 25 * Should we use the REST Endpoints of built BuddyPress?25 * Should we use BuddyPress core REST Endpoints? 26 26 * 27 27 * If the BP REST plugin is active, it overrides BuddyPress REST endpoints. 28 * This allows us to carry on maintaining all the BP REST API endpoints from 29 * the BP REST plugin on GitHub. 30 * 31 * @since 5.0.0 32 * 33 * @return bool Whether to use the REST Endpoints of built BuddyPress. 28 * 29 * @since 5.0.0 30 * 31 * @return bool Whether to use BuddyPress core REST endpoints. 34 32 */ 35 33 function bp_rest_in_buddypress() { 36 return ! bp_ is_running_from_src_subdirectory() && ! bp_rest_is_plugin_active();34 return ! bp_rest_is_plugin_active(); 37 35 } 38 36 … … 55 53 * @param bool $api_is_available True if the BP REST API is available. False otherwise. 56 54 */ 57 return apply_filters( 'bp_rest_api_is_available', bp_rest_in_buddypress() ) || bp_rest_is_plugin_active(); 58 } 59 60 /** 61 * Register the jQuery.ajax wrapper for BP REST API requests. 62 * 63 * @since 5.0.0 64 * @deprecated 10.0.0 65 */ 66 function bp_rest_api_register_request_script() { 67 if ( ! bp_rest_api_is_available() ) { 68 return; 69 } 70 71 wp_register_script( 72 'bp-api-request', 73 sprintf( '%1$sbp-core/js/bp-api-request%2$s.js', buddypress()->plugin_url, bp_core_get_minified_asset_suffix() ), 74 array( 'jquery', 'wp-api-request' ), 75 bp_get_version(), 76 true 77 ); 78 79 wp_localize_script( 80 'bp-api-request', 81 'bpApiSettings', 82 array( 83 'unexpectedError' => __( 'An unexpected error occured. Please try again.', 'buddypress' ), 84 'deprecatedWarning' => __( 'The bp.apiRequest function is deprecated since BuddyPress 10.0.0, please use wp.apiRequest instead.', 'buddypress' ), 85 ) 86 ); 87 } 88 add_action( 'bp_init', 'bp_rest_api_register_request_script' ); 55 return apply_filters( 'bp_rest_api_is_available', ( bp_rest_in_buddypress() || bp_rest_is_plugin_active() ) ); 56 } 89 57 90 58 /** … … 111 79 * 112 80 * @since 5.0.0 81 * @since 15.0.0 Version is now v2. 113 82 * 114 83 * @return string … … 120 89 * 121 90 * @since 5.0.0 122 * 123 * @param string $version BuddyPress core version. 91 * @since 15.0.0 Default version is now v2. 92 * 93 * @param string $bp_version BuddyPress REST API version. 124 94 */ 125 return apply_filters( 'bp_rest_version', 'v 1' );95 return apply_filters( 'bp_rest_version', 'v2' ); 126 96 } 127 97 … … 198 168 * 199 169 * @param string $value Comma-separated list of group types. 200 * @return array|null 170 * @return array|null|string 201 171 */ 202 172 function bp_rest_sanitize_member_types( $value ) { … … 210 180 $valid_types = array_intersect( $types, $registered_types ); 211 181 212 return ( ! empty( $valid_types )) ? $valid_types : null;182 return ! empty( $valid_types ) ? $valid_types : null; 213 183 } 214 184 … … 219 189 * 220 190 * @param mixed $value Mixed value. 221 * @return WP_Error| bool191 * @return WP_Error|true 222 192 */ 223 193 function bp_rest_validate_member_types( $value ) { … … 244 214 } 245 215 } 216 217 return true; 246 218 } 247 219 … … 251 223 * @since 5.0.0 252 224 * 253 * @param string $ valueComma-separated list of group types.225 * @param string $group_types Comma-separated list of group types. 254 226 * @return array|null 255 227 */ 256 function bp_rest_sanitize_group_types( $ value) {257 if ( empty( $ value) ) {228 function bp_rest_sanitize_group_types( $group_types ) { 229 if ( empty( $group_types ) ) { 258 230 return null; 259 231 } 260 232 261 $types = explode( ',', $ value);233 $types = explode( ',', $group_types ); 262 234 $valid_types = array_intersect( $types, bp_groups_get_group_types() ); 263 235 … … 270 242 * @since 5.0.0 271 243 * 272 * @param mixed $ valueMixed value.244 * @param mixed $group_types Mixed value. 273 245 * @return WP_Error|bool 274 246 */ 275 function bp_rest_validate_group_types( $ value) {276 if ( empty( $ value) ) {247 function bp_rest_validate_group_types( $group_types ) { 248 if ( empty( $group_types ) ) { 277 249 return true; 278 250 } 279 251 280 $types = explode( ',', $ value);252 $types = explode( ',', $group_types ); 281 253 $registered_types = bp_groups_get_group_types(); 282 254 foreach ( $types as $type ) { … … 293 265 } 294 266 } 267 268 return true; 295 269 } 296 270 … … 388 362 return isset( $registered_fields[ $attribute ] ); 389 363 } 364 365 /** 366 * Filter the WP REST API response to return a 404 if the request is for the V1 of the BP REST API. 367 * 368 * @param mixed $result Response to replace the requested version with. Can be anything 369 * a normal endpoint can return, or null to not hijack the request. 370 * @param WP_REST_Server $server Server instance. 371 * @param WP_REST_Request $request Request used to generate the response. 372 * 373 * @return mixed 374 */ 375 function bp_rest_api_v1_dispatch_error( $result, $server, $request ) { 376 377 // Bail early if the BP REST plugin is active. 378 if ( bp_rest_is_plugin_active() ) { 379 return $result; 380 } 381 382 $route = $request->get_route(); 383 384 if ( empty( $route ) || ! str_contains( $route, 'buddypress/v1' ) ) { 385 return $result; 386 } 387 388 return new WP_Error( 389 'rest_no_route', 390 __( 'The V1 of the BuddyPress REST API is no longer supported, use the V2 instead.', 'buddypress' ), 391 array( 'status' => 404 ) 392 ); 393 } 394 add_filter( 'rest_pre_dispatch', 'bp_rest_api_v1_dispatch_error', 10, 3 ); 395 396 /** 397 * Register the jQuery.ajax wrapper for BP REST API requests. 398 * 399 * @since 5.0.0 400 * @deprecated 10.0.0 401 */ 402 function bp_rest_api_register_request_script() { 403 if ( ! bp_rest_api_is_available() ) { 404 return; 405 } 406 407 wp_register_script( 408 'bp-api-request', 409 sprintf( '%1$sbp-core/js/bp-api-request%2$s.js', buddypress()->plugin_url, bp_core_get_minified_asset_suffix() ), 410 array( 'jquery', 'wp-api-request' ), 411 bp_get_version(), 412 true 413 ); 414 415 wp_localize_script( 416 'bp-api-request', 417 'bpApiSettings', 418 array( 419 'unexpectedError' => __( 'An unexpected error occurred. Please try again.', 'buddypress' ), 420 'deprecatedWarning' => __( 'The bp.apiRequest function is deprecated since BuddyPress 10.0.0, please use wp.apiRequest instead.', 'buddypress' ), 421 ) 422 ); 423 } 424 add_action( 'bp_init', 'bp_rest_api_register_request_script' ); -
trunk/src/bp-core/classes/class-bp-component.php
r13943 r14026 247 247 * 248 248 * @param string $id Unique ID. Letters, numbers, and underscores only. 249 * @param string $name Unique name. This should be a translatable name, eg. 250 * __( 'Groups', 'buddypress' ). 249 * @param string $name Unique name. This should be a translatable name, e.g. __( 'Groups', 'buddypress' ). 251 250 * @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}. 252 251 * @param array $params { … … 314 313 * if one is found, otherwise an empty string. 315 314 * @type bool $has_directory Set to true if the component requires an associated WordPress page. 316 * @type array $rewrite_ids The list of rewrit edIDs to use for the component.315 * @type array $rewrite_ids The list of rewritten IDs to use for the component. 317 316 * @type string $directory_title The title to use for the directory page. 318 317 * @type callable $notification_callback The callable function that formats the component's notifications. … … 530 529 531 530 foreach ( $paths as $path ) { 531 532 532 if ( @is_file( $slashed_path . $path ) ) { 533 533 require $slashed_path . $path; … … 623 623 // Register BP REST Endpoints. 624 624 if ( bp_rest_in_buddypress() && bp_rest_api_is_available() ) { 625 add_action( 'bp_rest_api_init', array( $this, 'rest_api_init' ) , 10);625 add_action( 'bp_rest_api_init', array( $this, 'rest_api_init' ) ); 626 626 } 627 627 … … 1416 1416 * @since 5.0.0 1417 1417 * 1418 * @param array$controllers The list of BP REST API controllers to load.1418 * @param string[] $controllers The list of BP REST API controllers to load. 1419 1419 */ 1420 1420 $controllers = (array) apply_filters( 'bp_' . $this->id . '_rest_api_controllers', $controllers ); … … 1425 1425 } 1426 1426 1427 if ( ! class_exists( $controller ) ) { 1428 _doing_it_wrong( 1429 __METHOD__, 1430 sprintf( 1431 // translators: %s: REST API controller class name. 1432 esc_html__( 'The REST API controller class %s does not exist.', 'buddypress' ), 1433 esc_attr( $controller ) 1434 ), 1435 '15.0.0' 1436 ); 1437 } 1438 1427 1439 $component_controller = new $controller(); 1428 1440 $component_controller->register_routes(); -
trunk/src/bp-core/classes/class-bp-core.php
r13979 r14026 441 441 */ 442 442 public function rest_api_init( $controllers = array() ) { 443 $controllers = array( 444 'BP_REST_Components_Endpoint', 445 ); 443 $controllers = array( 'BP_Core_Components_REST_Controller' ); 446 444 447 445 parent::rest_api_init( $controllers ); -
trunk/src/bp-core/classes/class-bp-rest-attachments-group-avatar-endpoint.php
r12607 r14026 1 <?php2 /**3 * BP REST: BP_REST_Attachments_Group_Avatar_Endpoint class4 *5 * @package BuddyPress6 * @deprecated 6.0.07 */8 9 defined( 'ABSPATH' ) || exit;10 11 _deprecated_file( basename( __FILE__ ), '6.0.0', 'bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php' );12 13 /** BP_REST_Attachments_Group_Avatar_Endpoint class */14 require_once trailingslashit( constant( 'BP_PLUGIN_DIR' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) ) . 'bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php'; -
trunk/src/bp-core/classes/class-bp-rest-attachments-member-avatar-endpoint.php
r12607 r14026 1 <?php2 /**3 * BP REST: BP_REST_Attachments_Member_Avatar_Endpoint class4 *5 * @package BuddyPress6 * @deprecated 6.0.07 */8 9 defined( 'ABSPATH' ) || exit;10 11 _deprecated_file( basename( __FILE__ ), '6.0.0', 'bp-members/classes/class-class-bp-rest-attachments-member-avatar-endpoint.php' );12 13 /** BP_REST_Attachments_Member_Avatar_Endpoint class */14 require_once trailingslashit( constant( 'BP_PLUGIN_DIR' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) ) . 'bp-members/classes/class-bp-rest-attachments-member-avatar-endpoint.php'; -
trunk/src/bp-friends/classes/class-bp-friends-component.php
r13503 r14026 140 140 'bp/friends' => array( 141 141 'widget_classnames' => array( 'widget_bp_core_friends_widget', 'buddypress' ), 142 ) 142 ), 143 143 ), 144 144 ); … … 160 160 */ 161 161 public function register_nav( $main_nav = array(), $sub_nav = array() ) { 162 $slug 162 $slug = bp_get_friends_slug(); 163 163 164 164 $main_nav = array( … … 306 306 $bp->bp_options_title = __( 'Friendships', 'buddypress' ); 307 307 } else { 308 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 309 'item_id' => bp_displayed_user_id(), 310 'type' => 'thumb', 311 'alt' => sprintf( 308 $bp->bp_options_avatar = bp_core_fetch_avatar( 309 array( 310 'item_id' => bp_displayed_user_id(), 311 'type' => 'thumb', 312 'alt' => sprintf( 312 313 /* translators: %s: member name */ 313 __( 'Profile picture of %s', 'buddypress' ), 314 bp_get_displayed_user_fullname() 315 ), 316 ) ); 317 $bp->bp_options_title = bp_get_displayed_user_fullname(); 314 __( 'Profile picture of %s', 'buddypress' ), 315 bp_get_displayed_user_fullname() 316 ), 317 ) 318 ); 319 $bp->bp_options_title = bp_get_displayed_user_fullname(); 318 320 } 319 321 } … … 330 332 331 333 // Global groups. 332 wp_cache_add_global_groups( array( 333 'bp_friends_requests', 334 'bp_friends_friendships', // Individual friendship objects are cached here by ID. 335 'bp_friends_friendships_for_user' // All friendship IDs for a single user. 336 ) ); 334 wp_cache_add_global_groups( 335 array( 336 'bp_friends_requests', 337 'bp_friends_friendships', // Individual friendship objects are cached here by ID. 338 'bp_friends_friendships_for_user', // All friendship IDs for a single user. 339 ) 340 ); 337 341 338 342 parent::setup_cache_groups(); … … 348 352 */ 349 353 public function rest_api_init( $controllers = array() ) { 350 parent::rest_api_init( array( 'BP_ REST_Friends_Endpoint' ) );354 parent::rest_api_init( array( 'BP_Friends_REST_Controller' ) ); 351 355 } 352 356 -
trunk/src/bp-groups/classes/class-bp-groups-component.php
r13689 r14026 338 338 339 339 // Check the parsed query is consistent with the Group’s registered screens. 340 add_action( 'bp_parse_query', 340 add_action( 'bp_parse_query', array( $this, 'check_parsed_query' ), 999, 0 ); 341 341 } 342 342 … … 448 448 * @param array $value Array of valid group statuses. 449 449 */ 450 $this->valid_status = apply_filters( 'groups_valid_status', array( 451 'public', 452 'private', 453 'hidden' 454 ) ); 450 $this->valid_status = apply_filters( 451 'groups_valid_status', 452 array( 453 'public', 454 'private', 455 'hidden', 456 ) 457 ); 455 458 456 459 // Auto join group when non group member performs group activity. … … 483 486 'table_name' => $bp->table_prefix . 'bp_groups', 484 487 'table_name_members' => $bp->table_prefix . 'bp_groups_members', 485 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta' 488 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta', 486 489 ); 487 490 … … 493 496 // Fetch the default directory title. 494 497 $default_directory_titles = bp_core_get_directory_page_default_titles(); 495 $default_directory_title = $default_directory_titles[ $this->id];498 $default_directory_title = $default_directory_titles[ $this->id ]; 496 499 497 500 // All globals for groups component. … … 610 613 * action variables. 611 614 */ 612 if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) 615 if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) { 613 616 unset( $bp->canonical_stack['action'] ); 614 617 } … … 635 638 'screen_function' => 'groups_screen_my_groups', 636 639 'default_subnav_slug' => 'my-groups', 637 'item_css_id' => $this->id 640 'item_css_id' => $this->id, 638 641 ); 639 642 … … 645 648 'screen_function' => 'groups_screen_my_groups', 646 649 'position' => 10, 647 'item_css_id' => 'groups-my-groups' 650 'item_css_id' => 'groups-my-groups', 648 651 ); 649 652 … … 709 712 'screen_function' => 'groups_screen_group_home', 710 713 'default_subnav_slug' => $this->default_extension, 711 'item_css_id' => $this->id 714 'item_css_id' => $this->id, 712 715 ), 713 716 'groups' … … 824 827 825 828 /** This action is documented in bp-groups/bp-groups-loader.php */ 826 do_action( 'groups_setup_nav' );829 do_action( 'groups_setup_nav' ); 827 830 } 828 831 } … … 852 855 if ( bp_is_active( 'groups', 'invitations' ) ) { 853 856 // Pending group invites. 854 $count 857 $count = groups_get_invite_count_for_user(); 855 858 if ( $count ) { 856 859 $title = sprintf( … … 907 910 ) 908 911 ), 909 'position' => 90 912 'position' => 90, 910 913 ); 911 914 } … … 925 928 $bp = buddypress(); 926 929 927 if ( bp_is_my_profile() && ! bp_is_single_item() ) {930 if ( bp_is_my_profile() && ! bp_is_single_item() ) { 928 931 $bp->bp_options_title = _x( 'Memberships', 'My Groups page <title>', 'buddypress' ); 929 932 930 } elseif ( !bp_is_my_profile() && !bp_is_single_item() ) { 931 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 932 'item_id' => bp_displayed_user_id(), 933 'type' => 'thumb', 934 'alt' => sprintf( 933 } elseif ( ! bp_is_my_profile() && ! bp_is_single_item() ) { 934 $bp->bp_options_avatar = bp_core_fetch_avatar( 935 array( 936 'item_id' => bp_displayed_user_id(), 937 'type' => 'thumb', 938 'alt' => sprintf( 935 939 /* translators: %s: member name */ 936 __( 'Profile picture of %s', 'buddypress' ), 937 bp_get_displayed_user_fullname() 938 ), 939 ) ); 940 $bp->bp_options_title = bp_get_displayed_user_fullname(); 941 942 // We are viewing a single group, so set up the 943 // group navigation menu using the $this->current_group global. 940 __( 'Profile picture of %s', 'buddypress' ), 941 bp_get_displayed_user_fullname() 942 ), 943 ) 944 ); 945 $bp->bp_options_title = bp_get_displayed_user_fullname(); 946 947 // We are viewing a single group, so set up the 948 // group navigation menu using the $this->current_group global. 944 949 } elseif ( bp_is_single_item() ) { 945 950 $bp->bp_options_title = $this->current_group->name; 946 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 947 'item_id' => $this->current_group->id, 948 'object' => 'group', 949 'type' => 'thumb', 950 'avatar_dir' => 'group-avatars', 951 'alt' => __( 'Group Profile Photo', 'buddypress' ) 952 ) ); 951 $bp->bp_options_avatar = bp_core_fetch_avatar( 952 array( 953 'item_id' => $this->current_group->id, 954 'object' => 'group', 955 'type' => 'thumb', 956 'avatar_dir' => 'group-avatars', 957 'alt' => __( 'Group Profile Photo', 'buddypress' ), 958 ) 959 ); 953 960 954 961 if ( empty( $bp->bp_options_avatar ) ) { … … 1028 1035 1029 1036 $rewrite_rules = array( 1030 'directory_type' => array(1037 'directory_type' => array( 1031 1038 'regex' => $this->root_slug . '/' . bp_get_groups_group_type_base() . '/([^/]+)/?$', 1032 1039 'order' => 50, 1033 1040 'query' => 'index.php?' . $this->rewrite_ids['directory'] . '=1&' . $this->rewrite_ids['directory_type'] . '=$matches[1]', 1034 1041 ), 1035 'create_single_item' => array(1042 'create_single_item' => array( 1036 1043 'regex' => $this->root_slug . '/' . $create_slug . '/?$', 1037 1044 'order' => 40, … … 1040 1047 'create_single_item_variables' => array( 1041 1048 'regex' => $this->root_slug . '/' . $create_slug . '/(.+?)/?$', 1042 'order' => 30,1049 'order' => 30, 1043 1050 'query' => 'index.php?' . $this->rewrite_ids['directory'] . '=1&' . $this->rewrite_ids['create_single_item'] . '=1&' . $this->rewrite_ids['create_single_item_variables'] . '=$matches[1]', 1044 1051 ), … … 1239 1246 public function rest_api_init( $controllers = array() ) { 1240 1247 $controllers = array( 1241 'BP_ REST_Groups_Endpoint',1242 'BP_ REST_Group_Membership_Endpoint',1243 'BP_ REST_Group_Invites_Endpoint',1244 'BP_ REST_Group_Membership_Request_Endpoint',1245 'BP_ REST_Attachments_Group_Avatar_Endpoint',1248 'BP_Groups_REST_Controller', 1249 'BP_Groups_Avatar_REST_Controller', 1250 'BP_Groups_Membership_REST_Controller', 1251 'BP_Groups_Membership_Request_REST_Controller', 1252 'BP_Groups_Invites_REST_Controller', 1246 1253 ); 1247 1254 1248 1255 // Support to Group Cover. 1249 1256 if ( bp_is_active( 'groups', 'cover_image' ) ) { 1250 $controllers[] = 'BP_ REST_Attachments_Group_Cover_Endpoint';1257 $controllers[] = 'BP_Groups_Cover_REST_Controller'; 1251 1258 } 1252 1259 … … 1266 1273 parent::blocks_init( 1267 1274 array( 1268 'bp/group' => array(1275 'bp/group' => array( 1269 1276 'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-groups/blocks/group', 1270 1277 'render_callback' => 'bp_groups_render_group_block', 1271 1278 ), 1272 'bp/groups' => array(1279 'bp/groups' => array( 1273 1280 'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-groups/blocks/groups', 1274 1281 'render_callback' => 'bp_groups_render_groups_block', -
trunk/src/bp-members/classes/class-bp-members-component.php
r14011 r14026 121 121 * bp-members/bp-members-template.php. 122 122 */ 123 $signup_allowed = apply_filters( 'bp_get_signup_allowed', (bool) bp_get_option( 'users_can_register' ) );123 $signup_allowed = apply_filters( 'bp_get_signup_allowed', (bool) bp_get_option( 'users_can_register' ) ); 124 124 $membership_requests_enabled = (bool) bp_get_option( 'bp-enable-membership-requests' ); 125 125 if ( bp_is_active( 'members', 'membership_requests' ) && ! $signup_allowed && $membership_requests_enabled ) { … … 166 166 167 167 // Action - Delete avatar. 168 if ( is_user_logged_in() && bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) {168 if ( is_user_logged_in() && bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) { 169 169 require_once $this->path . 'bp-members/actions/delete-avatar.php'; 170 170 } … … 216 216 217 217 // Check the parsed query is consistent with the Members navigation. 218 add_action( 'bp_parse_query', 218 add_action( 'bp_parse_query', array( $this, 'check_parsed_query' ), 999, 0 ); 219 219 } 220 220 … … 281 281 */ 282 282 283 $bp->signup = new stdClass ;283 $bp->signup = new stdClass(); 284 284 285 285 /** Profiles Fallback ************************************************ … … 287 287 288 288 if ( ! bp_is_active( 'xprofile' ) ) { 289 $bp->profile = new stdClass ;289 $bp->profile = new stdClass(); 290 290 $bp->profile->slug = 'profile'; 291 291 $bp->profile->id = 'profile'; … … 295 295 */ 296 296 297 $bp->members->invitations = new stdClass ;297 $bp->members->invitations = new stdClass(); 298 298 } 299 299 … … 328 328 // Fetch the default directory title. 329 329 $default_directory_titles = bp_core_get_directory_page_default_titles(); 330 $default_directory_title = $default_directory_titles[ $this->id];330 $default_directory_title = $default_directory_titles[ $this->id ]; 331 331 332 332 // Override any passed args. 333 333 $args = array( 334 'slug' => $default_slug,335 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $default_slug,336 'has_directory' => true,337 'rewrite_ids' => array(334 'slug' => $default_slug, 335 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $default_slug, 336 'has_directory' => true, 337 'rewrite_ids' => array( 338 338 'directory' => 'members', 339 339 'directory_type' => 'members_type', … … 346 346 'member_activate_key' => 'activate_key', 347 347 ), 348 'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title,349 'search_string' => __( 'Search Members...', 'buddypress' ),350 'global_tables' => array(348 'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title, 349 'search_string' => __( 'Search Members...', 'buddypress' ), 350 'global_tables' => array( 351 351 'table_name_invitations' => bp_core_get_table_prefix() . 'bp_invitations', 352 352 'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity', … … 359 359 'widget_classnames' => array( 'widget_bp_core_members_widget', 'buddypress' ), 360 360 ), 361 'bp/online-members' => array(361 'bp/online-members' => array( 362 362 'widget_classnames' => array( 'widget_bp_core_whos_online_widget', 'buddypress' ), 363 363 ), 364 'bp/active-members' => array(364 'bp/active-members' => array( 365 365 'widget_classnames' => array( 'widget_bp_core_recently_active_widget', 'buddypress' ), 366 366 ), … … 616 616 $wp_admin_nav = array_merge( $wp_admin_nav, $this->get_avatar_cover_image_admin_navs() ); 617 617 618 /**619 * The xProfile is active.620 *621 * Add the Change Avatar and Change Cover Image Admin Bar items622 * to the xProfile Admin Bar Menu.623 */618 /** 619 * The xProfile is active. 620 * 621 * Add the Change Avatar and Change Cover Image Admin Bar items 622 * to the xProfile Admin Bar Menu. 623 */ 624 624 } else { 625 625 add_filter( 'bp_xprofile_admin_nav', array( $this, 'setup_xprofile_admin_nav' ), 2 ); … … 661 661 } elseif ( bp_is_user() ) { 662 662 $bp->bp_options_title = bp_get_displayed_user_fullname(); 663 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 664 'item_id' => bp_displayed_user_id(), 665 'type' => 'thumb', 666 /* translators: %s: member name */ 667 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title ) 668 ) ); 663 $bp->bp_options_avatar = bp_core_fetch_avatar( 664 array( 665 'item_id' => bp_displayed_user_id(), 666 'type' => 'thumb', 667 /* translators: %s: member name */ 668 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title ), 669 ) 670 ); 669 671 } 670 672 … … 1062 1064 public function rest_api_init( $controllers = array() ) { 1063 1065 $controllers = array( 1064 'BP_ REST_Members_Endpoint',1065 'BP_ REST_Attachments_Member_Avatar_Endpoint',1066 'BP_Members_REST_Controller', 1067 'BP_Members_Avatar_REST_Controller', 1066 1068 ); 1067 1069 1068 1070 if ( bp_is_active( 'members', 'cover_image' ) ) { 1069 $controllers[] = 'BP_ REST_Attachments_Member_Cover_Endpoint';1071 $controllers[] = 'BP_Members_Cover_REST_Controller'; 1070 1072 } 1071 1073 1072 1074 if ( bp_get_signup_allowed() ) { 1073 $controllers[] = 'BP_ REST_Signup_Endpoint';1075 $controllers[] = 'BP_Members_Signup_REST_Controller'; 1074 1076 } 1075 1077 … … 1089 1091 parent::blocks_init( 1090 1092 array( 1091 'bp/member' => array(1093 'bp/member' => array( 1092 1094 'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-members/blocks/member', 1093 1095 'render_callback' => 'bp_members_render_member_block', 1094 1096 ), 1095 'bp/members' => array(1097 'bp/members' => array( 1096 1098 'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-members/blocks/members', 1097 1099 'render_callback' => 'bp_members_render_members_block', -
trunk/src/bp-messages/classes/class-bp-messages-component.php
r13551 r14026 42 42 array( 43 43 'adminbar_myaccount_order' => 50, 44 'features' => array( 'star' ) 44 'features' => array( 'star' ), 45 45 ) 46 46 ); … … 178 178 // All globals for messaging component. 179 179 // Note that global_tables is included in this array. 180 parent::setup_globals( array( 181 'slug' => $default_slug, 182 'has_directory' => false, 183 'notification_callback' => 'messages_format_notifications', 184 'search_string' => __( 'Search Messages...', 'buddypress' ), 185 'global_tables' => $global_tables, 186 'meta_tables' => $meta_tables 187 ) ); 180 parent::setup_globals( 181 array( 182 'slug' => $default_slug, 183 'has_directory' => false, 184 'notification_callback' => 'messages_format_notifications', 185 'search_string' => __( 'Search Messages...', 'buddypress' ), 186 'global_tables' => $global_tables, 187 'meta_tables' => $meta_tables, 188 ) 189 ); 188 190 } 189 191 … … 224 226 if ( bp_is_active( $this->id, 'star' ) ) { 225 227 $sub_nav[] = array( 226 'name' 228 'name' => __( 'Starred', 'buddypress' ), 227 229 'slug' => bp_get_messages_starred_slug(), 228 230 'parent_slug' => $slug, … … 325 327 // Unread message count. 326 328 $count = messages_get_unread_count( bp_loggedin_user_id() ); 327 if ( ! empty( $count ) ) {329 if ( ! empty( $count ) ) { 328 330 $title = sprintf( 329 331 /* translators: %s: Unread message count for the current user */ … … 338 340 } else { 339 341 $title = __( 'Messages', 'buddypress' ); 340 $inbox = __( 'Inbox', 342 $inbox = __( 'Inbox', 'buddypress' ); 341 343 } 342 344 … … 413 415 $bp->bp_options_title = __( 'My Messages', 'buddypress' ); 414 416 } else { 415 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 416 'item_id' => bp_displayed_user_id(), 417 'type' => 'thumb', 418 /* translators: %s: member name */ 419 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() ) 420 ) ); 421 $bp->bp_options_title = bp_get_displayed_user_fullname(); 417 $bp->bp_options_avatar = bp_core_fetch_avatar( 418 array( 419 'item_id' => bp_displayed_user_id(), 420 'type' => 'thumb', 421 /* translators: %s: member name */ 422 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() ), 423 ) 424 ); 425 $bp->bp_options_title = bp_get_displayed_user_fullname(); 422 426 } 423 427 } … … 434 438 435 439 // Global groups. 436 wp_cache_add_global_groups( array( 437 'bp_messages', 438 'bp_messages_threads', 439 'bp_messages_unread_count', 440 'message_meta' 441 ) ); 440 wp_cache_add_global_groups( 441 array( 442 'bp_messages', 443 'bp_messages_threads', 444 'bp_messages_unread_count', 445 'message_meta', 446 ) 447 ); 442 448 443 449 parent::setup_cache_groups(); … … 455 461 parent::rest_api_init( 456 462 array( 457 'BP_ REST_Messages_Endpoint',458 'BP_ REST_Sitewide_Notices_Endpoint',463 'BP_Messages_REST_Controller', 464 'BP_Messages_Sitewide_Notices_REST_Controller', 459 465 ) 460 466 ); -
trunk/src/bp-notifications/classes/class-bp-notifications-component.php
r13503 r14026 146 146 */ 147 147 public function register_nav( $main_nav = array(), $sub_nav = array() ) { 148 $slug 148 $slug = bp_get_notifications_slug(); 149 149 150 150 // Add 'Notifications' to the main navigation. … … 248 248 ); 249 249 } else { 250 $title = _x( 'Notifications', 'My Account Notification', 251 $unread = _x( 'Unread', 250 $title = _x( 'Notifications', 'My Account Notification', 'buddypress' ); 251 $unread = _x( 'Unread', 'My Account Notification sub nav', 'buddypress' ); 252 252 } 253 253 … … 297 297 } else { 298 298 $bp->bp_options_title = bp_get_displayed_user_fullname(); 299 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 300 'item_id' => bp_displayed_user_id(), 301 'type' => 'thumb', 302 /* translators: %s: member name */ 303 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() ) 304 ) ); 299 $bp->bp_options_avatar = bp_core_fetch_avatar( 300 array( 301 'item_id' => bp_displayed_user_id(), 302 'type' => 'thumb', 303 /* translators: %s: member name */ 304 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() ), 305 ) 306 ); 305 307 } 306 308 } … … 317 319 318 320 // Global groups. 319 wp_cache_add_global_groups( array( 320 'bp_notifications', 321 'notification_meta', 322 'bp_notifications_unread_count', 323 'bp_notifications_grouped_notifications', 324 ) ); 321 wp_cache_add_global_groups( 322 array( 323 'bp_notifications', 324 'notification_meta', 325 'bp_notifications_unread_count', 326 'bp_notifications_grouped_notifications', 327 ) 328 ); 325 329 326 330 parent::setup_cache_groups(); … … 336 340 */ 337 341 public function rest_api_init( $controllers = array() ) { 338 parent::rest_api_init( array( 'BP_ REST_Notifications_Endpoint' ) );342 parent::rest_api_init( array( 'BP_Notifications_REST_Controller' ) ); 339 343 } 340 344 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-component.php
r13503 r14026 174 174 // Register the visibility levels. See bp_xprofile_get_visibility_levels() to filter. 175 175 $this->visibility_levels = array( 176 'public' => array(177 'id' 176 'public' => array( 177 'id' => 'public', 178 178 'label' => _x( 'Everyone', 'Visibility level setting', 'buddypress' ), 179 179 ), 180 180 'adminsonly' => array( 181 'id' 181 'id' => 'adminsonly', 182 182 'label' => _x( 'Only Me', 'Visibility level setting', 'buddypress' ), 183 183 ), 184 'loggedin' => array(185 'id' 184 'loggedin' => array( 185 'id' => 'loggedin', 186 186 'label' => _x( 'All Members', 'Visibility level setting', 'buddypress' ), 187 187 ), … … 190 190 if ( bp_is_active( 'friends' ) ) { 191 191 $this->visibility_levels['friends'] = array( 192 'id' 193 'label' 192 'id' => 'friends', 193 'label' => _x( 'My Friends', 'Visibility level setting', 'buddypress' ), 194 194 ); 195 195 } … … 252 252 // Edit Profile. 253 253 $sub_nav[] = array( 254 'name' => _x( 'Edit', 'Profile header sub menu', 'buddypress' ),254 'name' => _x( 'Edit', 'Profile header sub menu', 'buddypress' ), 255 255 'slug' => 'edit', 256 256 'parent_slug' => $slug, … … 342 342 $bp->bp_options_title = _x( 'My Profile', 'Page title', 'buddypress' ); 343 343 } else { 344 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 345 'item_id' => bp_displayed_user_id(), 346 'type' => 'thumb', 347 348 /* translators: %s: member name */ 349 'alt' => sprintf( _x( 'Profile picture of %s', 'Avatar alt', 'buddypress' ), bp_get_displayed_user_fullname() ), 350 ) ); 351 $bp->bp_options_title = bp_get_displayed_user_fullname(); 344 $bp->bp_options_avatar = bp_core_fetch_avatar( 345 array( 346 'item_id' => bp_displayed_user_id(), 347 'type' => 'thumb', 348 349 /* translators: %s: member name */ 350 'alt' => sprintf( _x( 'Profile picture of %s', 'Avatar alt', 'buddypress' ), bp_get_displayed_user_fullname() ), 351 ) 352 ); 353 $bp->bp_options_title = bp_get_displayed_user_fullname(); 352 354 } 353 355 } … … 364 366 365 367 // Global groups. 366 wp_cache_add_global_groups( array( 367 'bp_xprofile', 368 'bp_xprofile_data', 369 'bp_xprofile_fields', 370 'bp_xprofile_groups', 371 'xprofile_meta', 372 'bp_user_mid', 373 ) ); 368 wp_cache_add_global_groups( 369 array( 370 'bp_xprofile', 371 'bp_xprofile_data', 372 'bp_xprofile_fields', 373 'bp_xprofile_groups', 374 'xprofile_meta', 375 'bp_user_mid', 376 ) 377 ); 374 378 375 379 parent::setup_cache_groups(); … … 405 409 */ 406 410 public function rest_api_init( $controllers = array() ) { 407 parent::rest_api_init( array( 408 'BP_REST_XProfile_Fields_Endpoint', 409 'BP_REST_XProfile_Field_Groups_Endpoint', 410 'BP_REST_XProfile_Data_Endpoint', 411 ) ); 411 parent::rest_api_init( 412 array( 413 'BP_XProfile_Fields_REST_Controller', 414 'BP_XProfile_Field_Groups_REST_Controller', 415 'BP_XProfile_Data_REST_Controller', 416 ) 417 ); 412 418 } 413 419 -
trunk/src/class-buddypress.php
r13953 r14026 657 657 require $this->plugin_dir . sprintf( 'bp-core/deprecated/%s.php', number_format( $deprecated_functions_version, 1 ) ); 658 658 } 659 659 } 660 660 661 661 // Load wp-cli module if PHP 5.6+. … … 674 674 * @since 2.5.0 675 675 * 676 * @param string $class Classes to be autoloaded. 677 * @return string Path of a class. 678 */ 679 public function autoload( $class ) { 680 $class_parts = explode( '_', strtolower( $class ) ); 676 * @param string $class_name Classes to be autoloaded. 677 */ 678 public function autoload( $class_name ) { 679 $class_parts = explode( '_', strtolower( $class_name ) ); 681 680 682 681 if ( 'bp' !== $class_parts[0] ) { … … 699 698 // These classes don't have a name that matches their component. 700 699 $irregular_map = array( 701 'BP_Akismet' => 'activity', 702 'BP_REST_Activity_Endpoint' => 'activity', 703 704 'BP_REST_Blogs_Endpoint' => 'blogs', 705 'BP_REST_Attachments_Blog_Avatar_Endpoint' => 'blogs', 706 707 'BP_Admin' => 'core', 708 'BP_Attachment_Avatar' => 'core', 709 'BP_Attachment_Cover_Image' => 'core', 710 'BP_Attachment' => 'core', 711 'BP_Button' => 'core', 712 'BP_Block' => 'core', 713 'BP_Component' => 'core', 714 'BP_Customizer_Control_Range' => 'core', 715 'BP_Date_Query' => 'core', 716 'BP_Email_Delivery' => 'core', 717 'BP_Email_Address' => 'core', 718 'BP_Email_Recipient' => 'core', 719 'BP_Email_Sender' => 'core', 720 'BP_Email_Participant' => 'core', 721 'BP_Email' => 'core', 722 'BP_Embed' => 'core', 723 'BP_Media_Extractor' => 'core', 724 'BP_Members_Suggestions' => 'core', 725 'BP_PHPMailer' => 'core', 726 'BP_Recursive_Query' => 'core', 727 'BP_Suggestions' => 'core', 728 'BP_Theme_Compat' => 'core', 729 'BP_User_Query' => 'core', 730 'BP_Walker_Category_Checklist' => 'core', 731 'BP_Walker_Nav_Menu' => 'core', 732 'BP_Invitation_Manager' => 'core', 733 'BP_Invitation' => 'core', 734 'BP_REST_Components_Endpoint' => 'core', 735 'BP_REST_Attachments' => 'core', 736 'BP_Admin_Types' => 'core', 737 'BP_Optout' => 'core', 738 'BP_Optouts_List_Table' => 'core', 739 740 'BP_REST_Friends_Endpoint' => 'friends', 741 742 'BP_Group_Extension' => 'groups', 743 'BP_Group_Member_Query' => 'groups', 744 'BP_REST_Groups_Endpoint' => 'groups', 745 'BP_REST_Group_Membership_Endpoint' => 'groups', 746 'BP_REST_Group_Invites_Endpoint' => 'groups', 747 'BP_REST_Group_Membership_Request_Endpoint' => 'groups', 748 'BP_REST_Attachments_Group_Avatar_Endpoint' => 'groups', 749 'BP_REST_Attachments_Group_Cover_Endpoint' => 'groups', 750 751 'BP_Core_Members_Template' => 'members', 752 'BP_Registration_Theme_Compat' => 'members', 753 'BP_Signup' => 'members', 754 'BP_REST_Members_Endpoint' => 'members', 755 'BP_REST_Attachments_Member_Avatar_Endpoint' => 'members', 756 'BP_REST_Attachments_Member_Cover_Endpoint' => 'members', 757 'BP_REST_Signup_Endpoint' => 'members', 758 'BP_Members_Invitation_Manager' => 'members', 759 'BP_Members_Invitations_Template' => 'members', 760 'BP_Members_Invitations_Component' => 'members', 761 762 'BP_REST_Messages_Endpoint' => 'messages', 763 'BP_REST_Sitewide_Notices_Endpoint' => 'messages', 764 765 'BP_REST_Notifications_Endpoint' => 'notifications', 766 767 'BP_REST_XProfile_Fields_Endpoint' => 'xprofile', 768 'BP_REST_XProfile_Field_Groups_Endpoint' => 'xprofile', 769 'BP_REST_XProfile_Data_Endpoint' => 'xprofile', 700 'BP_Akismet' => 'activity', 701 'BP_Admin' => 'core', 702 'BP_Attachment_Avatar' => 'core', 703 'BP_Attachment_Cover_Image' => 'core', 704 'BP_Attachment' => 'core', 705 'BP_Button' => 'core', 706 'BP_Block' => 'core', 707 'BP_Component' => 'core', 708 'BP_Customizer_Control_Range' => 'core', 709 'BP_Date_Query' => 'core', 710 'BP_Email_Delivery' => 'core', 711 'BP_Email_Address' => 'core', 712 'BP_Email_Recipient' => 'core', 713 'BP_Email_Sender' => 'core', 714 'BP_Email_Participant' => 'core', 715 'BP_Email' => 'core', 716 'BP_Embed' => 'core', 717 'BP_Media_Extractor' => 'core', 718 'BP_Members_Suggestions' => 'core', 719 'BP_PHPMailer' => 'core', 720 'BP_Recursive_Query' => 'core', 721 'BP_Suggestions' => 'core', 722 'BP_Theme_Compat' => 'core', 723 'BP_User_Query' => 'core', 724 'BP_Walker_Category_Checklist' => 'core', 725 'BP_Walker_Nav_Menu' => 'core', 726 'BP_Invitation_Manager' => 'core', 727 'BP_Invitation' => 'core', 728 'BP_REST_Attachments' => 'core', 729 'BP_Admin_Types' => 'core', 730 'BP_Optout' => 'core', 731 'BP_Optouts_List_Table' => 'core', 732 'BP_Group_Extension' => 'groups', 733 'BP_Group_Member_Query' => 'groups', 734 'BP_Core_Members_Template' => 'members', 735 'BP_Registration_Theme_Compat' => 'members', 736 'BP_Signup' => 'members', 737 'BP_Members_Invitation_Manager' => 'members', 738 'BP_Members_Invitations_Template' => 'members', 739 'BP_Members_Invitations_Component' => 'members', 770 740 ); 771 741 … … 773 743 774 744 // First check to see if the class is one without a properly namespaced name. 775 if ( isset( $irregular_map[ $class ] ) ) {776 $component = $irregular_map[ $class ];777 778 // Next chunk is usually the component name.745 if ( isset( $irregular_map[ $class_name ] ) ) { 746 $component = $irregular_map[ $class_name ]; 747 748 // Next chunk is usually the component name. 779 749 } elseif ( in_array( $class_parts[1], $components, true ) ) { 780 750 $component = $class_parts[1]; … … 786 756 787 757 // Sanitize class name. 788 $class = strtolower( str_replace( '_', '-', $class ) );758 $class = strtolower( str_replace( '_', '-', $class_name ) ); 789 759 790 760 if ( 'bp-rest-attachments' === $class ) { 791 $path = dirname( __FILE__ ). "/bp-{$component}/classes/trait-attachments.php";761 $path = __DIR__ . "/bp-{$component}/classes/trait-attachments.php"; 792 762 } else { 793 $path = dirname( __FILE__ ). "/bp-{$component}/classes/class-{$class}.php";763 $path = __DIR__ . "/bp-{$component}/classes/class-{$class}.php"; 794 764 } 795 765 … … 878 848 $this->db_version_raw = (int) $versions['1.6-single']; 879 849 880 // If no 1.6-single exists, use the max of the others.850 // If no 1.6-single exists, use the max of the others. 881 851 } else { 882 852 $versions['1.2'] = get_site_option( 'bp-core-db-version' ); -
trunk/tests/phpunit/assets/bp-rest-api-controllers.php
r13414 r14026 1 <?php2 /**3 * BP REST Controllers' mocks4 */5 6 class BP_REST_Mock_Class {7 public function __construct() {}8 9 public function register_routes( $controller = '' ) {10 array_push( buddypress()->unit_test_rest->controllers, $controller );11 }12 }13 14 /**15 * BP Member Cover Image REST Controller's mock.16 */17 #[AllowDynamicProperties]18 class BP_REST_Attachments_Member_Cover_Endpoint extends BP_REST_Mock_Class {19 public function __construct() {20 $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();21 $this->rest_base = 'members';22 }23 24 public function register_routes( $controller = '' ) {25 parent::register_routes( 'BP_REST_Attachments_Member_Cover_Endpoint' );26 }27 }28 29 /**30 * BP Member Avatar REST Controller's mock.31 */32 #[AllowDynamicProperties]33 class BP_REST_Attachments_Member_Avatar_Endpoint extends BP_REST_Mock_Class {34 public function __construct() {35 $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();36 $this->rest_base = 'members';37 }38 39 public function register_routes( $controller = '' ) {40 parent::register_routes( 'BP_REST_Attachments_Member_Avatar_Endpoint' );41 }42 }43 44 /**45 * BP Components REST Controller's mock.46 */47 #[AllowDynamicProperties]48 class BP_REST_Components_Endpoint extends BP_REST_Mock_Class {49 public function __construct() {50 $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();51 $this->rest_base = 'components';52 }53 54 public function register_routes( $controller = '' ) {55 parent::register_routes( 'BP_REST_Components_Endpoint' );56 }57 }58 59 /**60 * BP Members REST Controller's mock.61 */62 #[AllowDynamicProperties]63 class BP_REST_Members_Endpoint extends BP_REST_Mock_Class {64 public function __construct() {65 $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();66 $this->rest_base = 'members';67 }68 69 public function register_routes( $controller = '' ) {70 parent::register_routes( 'BP_REST_Members_Endpoint' );71 }72 } -
trunk/tests/phpunit/bootstrap.php
r13720 r14026 2 2 const WP_TESTS_PHPUNIT_POLYFILLS_PATH = __DIR__ . '/../../vendor/yoast/phpunit-polyfills'; 3 3 4 require ( dirname( __FILE__ ) . '/includes/define-constants.php' );4 require __DIR__ . '/includes/define-constants.php'; 5 5 6 6 if ( ! file_exists( WP_TESTS_DIR . '/includes/functions.php' ) ) { … … 17 17 require WP_TESTS_DIR . '/includes/bootstrap.php'; 18 18 19 // Load the BP-specific testing tools 19 // Load the BP-specific testing tools. 20 20 require BP_TESTS_DIR . '/includes/testcase.php'; 21 21 require BP_TESTS_DIR . '/includes/testcase-emails.php'; 22 require BP_TESTS_DIR . '/includes/testcase-rest-controller.php'; 23 24 /** 25 * Set component visibility. 26 * 27 * @param bool $visibility Visibility. 28 */ 29 function toggle_component_visibility( $visibility = true ) { 30 $visibility = $visibility ? 'members' : 'anyone'; 31 32 update_option( 33 '_bp_community_visibility', 34 array( 35 'global' => $visibility, 36 'activity' => $visibility, 37 'members' => $visibility, 38 'groups' => $visibility, 39 'blogs' => $visibility, 40 ) 41 ); 42 } -
trunk/tests/phpunit/testcases/activity/template.php
r13980 r14026 9 9 */ 10 10 public function test_user_can_delete() { 11 $bp = buddypress();12 $u = self::factory()->user->create();11 $bp = buddypress(); 12 $u = self::factory()->user->create(); 13 13 $original_user = bp_loggedin_user_id(); 14 14 self::set_current_user( $u ); 15 15 16 $a = self::factory()->activity->create( array( 17 'type' => 'activity_update', 18 'user_id' => $u, 19 ) ); 16 $a = self::factory()->activity->create( 17 array( 18 'type' => 'activity_update', 19 'user_id' => $u, 20 ) 21 ); 20 22 21 23 // User can delete his own items … … 28 30 29 31 // Miscellaneous user can't delete 30 $misc_user = self::factory()->user->create( array( 'role' => 'subscriber' ));32 $misc_user = self::factory()->user->create(); 31 33 self::set_current_user( $misc_user ); 32 34 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 33 35 34 36 // Item admin can delete 35 $is_single_item = $bp->is_single_item;37 $is_single_item = $bp->is_single_item; 36 38 $bp->is_single_item = true; 37 39 38 $is_item_admin = $bp->is_item_admin;40 $is_item_admin = $bp->is_item_admin; 39 41 $bp->is_item_admin = true; 40 42 … … 42 44 43 45 $bp->is_single_item = $is_single_item; 44 $bp->is_item_admin = $is_item_admin;46 $bp->is_item_admin = $is_item_admin; 45 47 self::set_current_user( $original_user ); 46 48 } … … 52 54 // save the current user and override logged-in user 53 55 $old_user = get_current_user_id(); 54 $u = self::factory()->user->create();56 $u = self::factory()->user->create(); 55 57 self::set_current_user( $u ); 56 58 57 59 // create an activity update for the user 58 self::factory()->activity->create( array( 59 'component' => buddypress()->activity->id, 60 'type' => 'activity_update', 61 'user_id' => $u, 62 ) ); 60 self::factory()->activity->create( 61 array( 62 'component' => buddypress()->activity->id, 63 'type' => 'activity_update', 64 'user_id' => $u, 65 ) 66 ); 63 67 64 68 // start the activity loop 65 69 bp_has_activities( array( 'user_id' => $u ) ); 66 while ( bp_activities() ) : bp_the_activity(); 70 while ( bp_activities() ) : 71 bp_the_activity(); 67 72 // assert! 68 73 $this->assertTrue( bp_activity_user_can_delete() ); … … 81 86 */ 82 87 public function test_bp_has_activities_favorites_action_filter() { 83 $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 84 85 $now = time(); 86 87 $a1 = self::factory()->activity->create( array( 88 'type' => 'activity_update', 89 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 90 ) ); 91 92 $a2 = self::factory()->activity->create( array( 93 'type' => 'joined_group', 94 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 95 ) ); 88 $user_id = self::factory()->user->create(); 89 90 $now = time(); 91 92 $a1 = self::factory()->activity->create( 93 array( 94 'type' => 'activity_update', 95 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 96 ) 97 ); 98 99 $a2 = self::factory()->activity->create( 100 array( 101 'type' => 'joined_group', 102 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 103 ) 104 ); 96 105 97 106 $current_user = bp_loggedin_user_id(); … … 107 116 108 117 // Case 1: no action filter 109 bp_has_activities( array( 110 'user_id' => $user_id, 111 'scope' => 'favorites', 112 ) ); 118 bp_has_activities( 119 array( 120 'user_id' => $user_id, 121 'scope' => 'favorites', 122 ) 123 ); 113 124 114 125 // The formatting of $activities_template->activities is messed … … 122 133 123 134 // Case 2: action filter 124 bp_has_activities( array( 125 'user_id' => $user_id, 126 'scope' => 'favorites', 127 'action' => 'activity_update', 128 ) ); 135 bp_has_activities( 136 array( 137 'user_id' => $user_id, 138 'scope' => 'favorites', 139 'action' => 'activity_update', 140 ) 141 ); 129 142 130 143 $ids = wp_list_pluck( $activities_template->activities, 'id' ); … … 151 164 152 165 // activity item 153 $a1 = self::factory()->activity->create( array( 154 'user_id' => $u1, 155 'component' => 'activity', 156 'type' => 'activity_update', 157 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 158 ) ); 166 $a1 = self::factory()->activity->create( 167 array( 168 'user_id' => $u1, 169 'component' => 'activity', 170 'type' => 'activity_update', 171 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 172 ) 173 ); 159 174 160 175 // misc activity items 161 176 162 self::factory()->activity->create( array( 163 'user_id' => $u2, 164 'component' => 'activity', 165 'type' => 'activity_update', 166 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 167 ) ); 168 self::factory()->activity->create( array( 169 'user_id' => $u2, 170 'component' => 'groups', 171 'item_id' => 324, 172 'type' => 'activity_update', 173 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 174 ) ); 177 self::factory()->activity->create( 178 array( 179 'user_id' => $u2, 180 'component' => 'activity', 181 'type' => 'activity_update', 182 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 183 ) 184 ); 185 self::factory()->activity->create( 186 array( 187 'user_id' => $u2, 188 'component' => 'groups', 189 'item_id' => 324, 190 'type' => 'activity_update', 191 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 192 ) 193 ); 175 194 176 195 global $activities_template; … … 178 197 // grab just-me scope with no user ID 179 198 // user ID should fallback to logged-in user ID 180 bp_has_activities( array( 181 'user_id' => false, 182 'scope' => 'just-me', 183 ) ); 199 bp_has_activities( 200 array( 201 'user_id' => false, 202 'scope' => 'just-me', 203 ) 204 ); 184 205 185 206 // assert! … … 204 225 // mentioned activity item 205 226 $mention_username = '@' . bp_activity_get_user_mentionname( $u1 ); 206 $a1 = self::factory()->activity->create( array( 207 'user_id' => $u2, 208 'type' => 'activity_update', 209 'content' => "{$mention_username} - You rule, dude!", 210 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 211 ) ); 227 $a1 = self::factory()->activity->create( 228 array( 229 'user_id' => $u2, 230 'type' => 'activity_update', 231 'content' => "{$mention_username} - You rule, dude!", 232 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 233 ) 234 ); 212 235 213 236 // misc activity items 214 self::factory()->activity->create( array( 215 'user_id' => $u1, 216 'component' => 'blogs', 217 'item_id' => 1, 218 'type' => 'new_blog_post', 219 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 220 ) ); 221 self::factory()->activity->create( array( 222 'user_id' => $u2, 223 'component' => 'activity', 224 'type' => 'activity_update', 225 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 226 ) ); 227 self::factory()->activity->create( array( 228 'user_id' => $u2, 229 'component' => 'groups', 230 'item_id' => 324, 231 'type' => 'activity_update', 232 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 233 ) ); 237 self::factory()->activity->create( 238 array( 239 'user_id' => $u1, 240 'component' => 'blogs', 241 'item_id' => 1, 242 'type' => 'new_blog_post', 243 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 244 ) 245 ); 246 self::factory()->activity->create( 247 array( 248 'user_id' => $u2, 249 'component' => 'activity', 250 'type' => 'activity_update', 251 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 252 ) 253 ); 254 self::factory()->activity->create( 255 array( 256 'user_id' => $u2, 257 'component' => 'groups', 258 'item_id' => 324, 259 'type' => 'activity_update', 260 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 261 ) 262 ); 234 263 235 264 global $activities_template; 236 265 237 266 // grab activities from multiple scopes 238 bp_has_activities( array( 239 'user_id' => $u1, 240 'scope' => 'mentions', 241 ) ); 267 bp_has_activities( 268 array( 269 'user_id' => $u1, 270 'scope' => 'mentions', 271 ) 272 ); 242 273 243 274 // assert! … … 264 295 265 296 // friend status update 266 $a1 = self::factory()->activity->create( array( 267 'user_id' => $u2, 268 'type' => 'activity_update', 269 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 270 ) ); 297 $a1 = self::factory()->activity->create( 298 array( 299 'user_id' => $u2, 300 'type' => 'activity_update', 301 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 302 ) 303 ); 271 304 272 305 // mentioned item by non-friend 273 306 $mention_username = '@' . bp_activity_get_user_mentionname( $u1 ); 274 $a2 = self::factory()->activity->create( array( 275 'user_id' => $u3, 276 'component' => 'activity', 277 'type' => 'activity_update', 278 'content' => "{$mention_username} - Oy!", 279 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 280 ) ); 307 $a2 = self::factory()->activity->create( 308 array( 309 'user_id' => $u3, 310 'component' => 'activity', 311 'type' => 'activity_update', 312 'content' => "{$mention_username} - Oy!", 313 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 314 ) 315 ); 281 316 282 317 // misc activity items 283 self::factory()->activity->create( array( 284 'user_id' => $u1, 285 'component' => 'blogs', 286 'item_id' => 1, 287 'type' => 'new_blog_post', 288 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 289 ) ); 290 self::factory()->activity->create( array( 291 'user_id' => $u3, 292 'component' => 'activity', 293 'type' => 'activity_update', 294 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 295 ) ); 296 self::factory()->activity->create( array( 297 'user_id' => $u3, 298 'component' => 'groups', 299 'item_id' => 324, 300 'type' => 'activity_update', 301 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 302 ) ); 318 self::factory()->activity->create( 319 array( 320 'user_id' => $u1, 321 'component' => 'blogs', 322 'item_id' => 1, 323 'type' => 'new_blog_post', 324 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 325 ) 326 ); 327 self::factory()->activity->create( 328 array( 329 'user_id' => $u3, 330 'component' => 'activity', 331 'type' => 'activity_update', 332 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 333 ) 334 ); 335 self::factory()->activity->create( 336 array( 337 'user_id' => $u3, 338 'component' => 'groups', 339 'item_id' => 324, 340 'type' => 'activity_update', 341 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 342 ) 343 ); 303 344 304 345 global $activities_template; 305 346 306 347 // grab activities from multiple scopes 307 bp_has_activities( array( 308 'user_id' => $u1, 309 'scope' => 'mentions,friends', 310 ) ); 348 bp_has_activities( 349 array( 350 'user_id' => $u1, 351 'scope' => 'mentions,friends', 352 ) 353 ); 311 354 312 355 // assert! … … 337 380 338 381 // friend status update 339 $a1 = self::factory()->activity->create( array( 340 'user_id' => $u2, 341 'type' => 'activity_update', 342 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 343 ) ); 382 $a1 = self::factory()->activity->create( 383 array( 384 'user_id' => $u2, 385 'type' => 'activity_update', 386 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 387 ) 388 ); 344 389 345 390 // group activity 346 $a2 = self::factory()->activity->create( array( 347 'user_id' => $u3, 348 'component' => 'groups', 349 'item_id' => $g1, 350 'type' => 'joined_group', 351 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 352 ) ); 391 $a2 = self::factory()->activity->create( 392 array( 393 'user_id' => $u3, 394 'component' => 'groups', 395 'item_id' => $g1, 396 'type' => 'joined_group', 397 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 398 ) 399 ); 353 400 354 401 // misc activity items 355 self::factory()->activity->create( array( 356 'user_id' => $u3, 357 'component' => 'blogs', 358 'item_id' => 1, 359 'type' => 'new_blog_post', 360 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 361 ) ); 362 self::factory()->activity->create( array( 363 'user_id' => $u3, 364 'component' => 'activity', 365 'type' => 'activity_update', 366 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 367 ) ); 402 self::factory()->activity->create( 403 array( 404 'user_id' => $u3, 405 'component' => 'blogs', 406 'item_id' => 1, 407 'type' => 'new_blog_post', 408 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 409 ) 410 ); 411 self::factory()->activity->create( 412 array( 413 'user_id' => $u3, 414 'component' => 'activity', 415 'type' => 'activity_update', 416 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 417 ) 418 ); 368 419 369 420 // Make sure we get a fake group ID. 370 421 global $wpdb, $bp; 371 422 $max_group_id = $wpdb->get_var( "SELECT id FROM {$bp->groups->table_name} ORDER BY id DESC LIMIT 1" ); 372 self::factory()->activity->create( array( 373 'user_id' => $u3, 374 'component' => 'groups', 375 'item_id' => $max_group_id + 1, 376 'type' => 'activity_update', 377 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 378 ) ); 423 self::factory()->activity->create( 424 array( 425 'user_id' => $u3, 426 'component' => 'groups', 427 'item_id' => $max_group_id + 1, 428 'type' => 'activity_update', 429 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 430 ) 431 ); 379 432 380 433 global $activities_template; 381 434 382 435 // grab activities from multiple scopes 383 bp_has_activities( array( 384 'user_id' => $u1, 385 'scope' => 'groups,friends', 386 ) ); 436 bp_has_activities( 437 array( 438 'user_id' => $u1, 439 'scope' => 'groups,friends', 440 ) 441 ); 387 442 388 443 // assert! … … 404 459 405 460 // Create a random activity 406 self::factory()->activity->create( array( 407 'user_id' => $u1, 408 'type' => 'activity_update', 409 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 410 ) ); 461 self::factory()->activity->create( 462 array( 463 'user_id' => $u1, 464 'type' => 'activity_update', 465 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 466 ) 467 ); 411 468 412 469 global $activities_template; … … 414 471 415 472 // grab activities from friends scope 416 bp_has_activities( array( 417 'user_id' => $u1, 418 'scope' => 'friends', 419 ) ); 473 bp_has_activities( 474 array( 475 'user_id' => $u1, 476 'scope' => 'friends', 477 ) 478 ); 420 479 421 480 // assert! … … 437 496 438 497 // Create a random activity 439 self::factory()->activity->create( array( 440 'user_id' => $u1, 441 'type' => 'activity_update', 442 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 443 ) ); 498 self::factory()->activity->create( 499 array( 500 'user_id' => $u1, 501 'type' => 'activity_update', 502 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 503 ) 504 ); 444 505 445 506 global $activities_template; … … 447 508 448 509 // grab activities from favorites scope 449 bp_has_activities( array( 450 'user_id' => $u1, 451 'scope' => 'favorites', 452 ) ); 510 bp_has_activities( 511 array( 512 'user_id' => $u1, 513 'scope' => 'favorites', 514 ) 515 ); 453 516 454 517 // assert! … … 470 533 471 534 // Create a random activity 472 self::factory()->activity->create( array( 473 'user_id' => $u1, 474 'type' => 'activity_update', 475 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 476 ) ); 535 self::factory()->activity->create( 536 array( 537 'user_id' => $u1, 538 'type' => 'activity_update', 539 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 540 ) 541 ); 477 542 478 543 global $activities_template; … … 480 545 481 546 // grab activities from groups scope 482 bp_has_activities( array( 483 'user_id' => $u1, 484 'scope' => 'groups', 485 ) ); 547 bp_has_activities( 548 array( 549 'user_id' => $u1, 550 'scope' => 'groups', 551 ) 552 ); 486 553 487 554 // assert! … … 503 570 504 571 // Create a random activity 505 self::factory()->activity->create( array( 506 'user_id' => $u1, 507 'type' => 'activity_update', 508 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 509 ) ); 572 self::factory()->activity->create( 573 array( 574 'user_id' => $u1, 575 'type' => 'activity_update', 576 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 577 ) 578 ); 510 579 511 580 global $activities_template; … … 513 582 514 583 // grab activities from mentions scope 515 bp_has_activities( array( 516 'user_id' => $u1, 517 'scope' => 'mentions', 518 ) ); 584 bp_has_activities( 585 array( 586 'user_id' => $u1, 587 'scope' => 'mentions', 588 ) 589 ); 519 590 520 591 // assert! … … 536 607 537 608 // Friend's very fast status updates. 538 $a1 = self::factory()->activity->create( array( 539 'user_id' => $u2, 540 'type' => 'activity_update', 541 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 542 ) ); 543 $a2 = self::factory()->activity->create( array( 544 'user_id' => $u2, 545 'type' => 'activity_update', 546 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 547 ) ); 609 $a1 = self::factory()->activity->create( 610 array( 611 'user_id' => $u2, 612 'type' => 'activity_update', 613 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 614 ) 615 ); 616 $a2 = self::factory()->activity->create( 617 array( 618 'user_id' => $u2, 619 'type' => 'activity_update', 620 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 621 ) 622 ); 548 623 549 624 global $activities_template; … … 551 626 552 627 // Get activities in 'friends' scope 553 bp_has_activities( array( 554 'user_id' => $u1, 555 'scope' => 'friends', 556 ) ); 628 bp_has_activities( 629 array( 630 'user_id' => $u1, 631 'scope' => 'friends', 632 ) 633 ); 557 634 558 635 $found = $activities_template->activities; … … 576 653 577 654 // Two user join first user's group same time 578 $a1 = self::factory()->activity->create( array( 579 'user_id' => $u2, 580 'component' => 'groups', 581 'item_id' => $g1, 582 'type' => 'joined_group', 583 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 584 ) ); 585 $a2 = self::factory()->activity->create( array( 586 'user_id' => $u3, 587 'component' => 'groups', 588 'item_id' => $g1, 589 'type' => 'joined_group', 590 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 591 ) ); 655 $a1 = self::factory()->activity->create( 656 array( 657 'user_id' => $u2, 658 'component' => 'groups', 659 'item_id' => $g1, 660 'type' => 'joined_group', 661 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 662 ) 663 ); 664 $a2 = self::factory()->activity->create( 665 array( 666 'user_id' => $u3, 667 'component' => 'groups', 668 'item_id' => $g1, 669 'type' => 'joined_group', 670 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), 671 ) 672 ); 592 673 593 674 global $activities_template; … … 595 676 596 677 // Get activities in 'groups' scope 597 bp_has_activities( array( 598 'user_id' => $u1, 599 'scope' => 'groups', 600 ) ); 678 bp_has_activities( 679 array( 680 'user_id' => $u1, 681 'scope' => 'groups', 682 ) 683 ); 601 684 602 685 $found = $activities_template->activities; … … 619 702 $now = time(); 620 703 621 $a1 = self::factory()->activity->create( array( 622 'user_id' => $u3, 623 'component' => 'blogs', 624 'item_id' => 1, 625 'type' => 'new_blog_post', 626 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 627 ) ); 628 $a2 = self::factory()->activity->create( array( 629 'user_id' => $u2, 630 'component' => 'activity', 631 'type' => 'activity_update', 632 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 633 ) ); 704 $a1 = self::factory()->activity->create( 705 array( 706 'user_id' => $u3, 707 'component' => 'blogs', 708 'item_id' => 1, 709 'type' => 'new_blog_post', 710 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 711 ) 712 ); 713 $a2 = self::factory()->activity->create( 714 array( 715 'user_id' => $u2, 716 'component' => 'activity', 717 'type' => 'activity_update', 718 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 719 ) 720 ); 634 721 635 722 // misc activity items 636 self::factory()->activity->create( array( 637 'user_id' => $u3, 638 'component' => 'activity', 639 'type' => 'activity_update', 640 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 641 ) ); 642 self::factory()->activity->create( array( 643 'user_id' => $u3, 644 'component' => 'groups', 645 'item_id' => 324, 646 'type' => 'activity_update', 647 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 648 ) ); 649 650 global $activities_template; 651 652 bp_has_activities( array( 653 'filter_query' => array( 654 'relation' => 'OR', 655 array( 656 'column' => 'component', 657 'value' => 'blogs', 658 ), 659 array( 660 'relation' => 'AND', 723 self::factory()->activity->create( 724 array( 725 'user_id' => $u3, 726 'component' => 'activity', 727 'type' => 'activity_update', 728 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 729 ) 730 ); 731 self::factory()->activity->create( 732 array( 733 'user_id' => $u3, 734 'component' => 'groups', 735 'item_id' => 324, 736 'type' => 'activity_update', 737 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 738 ) 739 ); 740 741 global $activities_template; 742 743 bp_has_activities( 744 array( 745 'filter_query' => array( 746 'relation' => 'OR', 661 747 array( 662 'column' => ' type',663 'value' => ' activity_update',748 'column' => 'component', 749 'value' => 'blogs', 664 750 ), 665 751 array( 666 'column' => 'user_id', 667 'value' => $u2, 752 'relation' => 'AND', 753 array( 754 'column' => 'type', 755 'value' => 'activity_update', 756 ), 757 array( 758 'column' => 'user_id', 759 'value' => $u2, 760 ), 668 761 ), 669 762 ), 670 763 ) 671 ) );764 ); 672 765 673 766 // assert! … … 690 783 691 784 // misc activity items 692 $a1 = self::factory()->activity->create( array( 693 'user_id' => $u3, 694 'component' => 'blogs', 695 'item_id' => 1, 696 'type' => 'new_blog_post', 697 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 698 ) ); 699 $a2 = self::factory()->activity->create( array( 700 'user_id' => $u2, 701 'component' => 'activity', 702 'type' => 'activity_update', 703 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 704 ) ); 705 $a3 = self::factory()->activity->create( array( 706 'user_id' => $u3, 707 'component' => 'activity', 708 'type' => 'activity_update', 709 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 710 ) ); 711 $a4 = self::factory()->activity->create( array( 712 'user_id' => $u3, 713 'component' => 'groups', 714 'item_id' => 324, 715 'type' => 'activity_update', 716 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 717 ) ); 718 719 global $activities_template; 720 721 bp_has_activities( array( 722 'filter_query' => array( 723 array( 724 'column' => 'id', 725 'compare' => 'NOT IN', 726 'value' => array( $a1, $a4 ), 785 $a1 = self::factory()->activity->create( 786 array( 787 'user_id' => $u3, 788 'component' => 'blogs', 789 'item_id' => 1, 790 'type' => 'new_blog_post', 791 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 792 ) 793 ); 794 $a2 = self::factory()->activity->create( 795 array( 796 'user_id' => $u2, 797 'component' => 'activity', 798 'type' => 'activity_update', 799 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 800 ) 801 ); 802 $a3 = self::factory()->activity->create( 803 array( 804 'user_id' => $u3, 805 'component' => 'activity', 806 'type' => 'activity_update', 807 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 808 ) 809 ); 810 $a4 = self::factory()->activity->create( 811 array( 812 'user_id' => $u3, 813 'component' => 'groups', 814 'item_id' => 324, 815 'type' => 'activity_update', 816 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 817 ) 818 ); 819 820 global $activities_template; 821 822 bp_has_activities( 823 array( 824 'filter_query' => array( 825 array( 826 'column' => 'id', 827 'compare' => 'NOT IN', 828 'value' => array( $a1, $a4 ), 829 ), 727 830 ), 728 831 ) 729 ) );832 ); 730 833 731 834 // assert! … … 746 849 747 850 // misc activity items 748 $a1 = self::factory()->activity->create( array( 749 'user_id' => $u1, 750 'component' => 'blogs', 751 'item_id' => 1, 752 'type' => 'new_blog_post', 753 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 754 ) ); 755 $a2 = self::factory()->activity->create( array( 756 'user_id' => $u1, 757 'component' => 'activity', 758 'type' => 'activity_update', 759 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 760 ) ); 761 $a3 = self::factory()->activity->create( array( 762 'user_id' => $u1, 763 'component' => 'activity', 764 'type' => 'activity_update', 765 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 766 ) ); 767 $a4 = self::factory()->activity->create( array( 768 'user_id' => $u1, 769 'component' => 'groups', 770 'item_id' => 324, 771 'type' => 'activity_update', 772 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 773 ) ); 774 775 global $activities_template; 776 777 bp_has_activities( array( 778 'filter_query' => array( 779 array( 780 'column' => 'id', 781 'compare' => 'BETWEEN', 782 'value' => array( $a3, $a4 ), 851 $a1 = self::factory()->activity->create( 852 array( 853 'user_id' => $u1, 854 'component' => 'blogs', 855 'item_id' => 1, 856 'type' => 'new_blog_post', 857 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 858 ) 859 ); 860 $a2 = self::factory()->activity->create( 861 array( 862 'user_id' => $u1, 863 'component' => 'activity', 864 'type' => 'activity_update', 865 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 866 ) 867 ); 868 $a3 = self::factory()->activity->create( 869 array( 870 'user_id' => $u1, 871 'component' => 'activity', 872 'type' => 'activity_update', 873 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 874 ) 875 ); 876 $a4 = self::factory()->activity->create( 877 array( 878 'user_id' => $u1, 879 'component' => 'groups', 880 'item_id' => 324, 881 'type' => 'activity_update', 882 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 883 ) 884 ); 885 886 global $activities_template; 887 888 bp_has_activities( 889 array( 890 'filter_query' => array( 891 array( 892 'column' => 'id', 893 'compare' => 'BETWEEN', 894 'value' => array( $a3, $a4 ), 895 ), 783 896 ), 784 897 ) 785 ) );898 ); 786 899 787 900 // assert! … … 802 915 803 916 // misc activity items 804 $a1 = self::factory()->activity->create( array( 805 'user_id' => $u1, 806 'component' => 'activity', 807 'item_id' => 1, 808 'type' => 'activity_update', 809 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 810 ) ); 811 $a2 = self::factory()->activity->create( array( 812 'user_id' => $u1, 813 'component' => 'activity', 814 'item_id' => 10, 815 'type' => 'activity_update', 816 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 817 ) ); 818 $a3 = self::factory()->activity->create( array( 819 'user_id' => $u1, 820 'component' => 'activity', 821 'item_id' => 25, 822 'type' => 'activity_update', 823 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 824 ) ); 825 $a4 = self::factory()->activity->create( array( 826 'user_id' => $u1, 827 'component' => 'activity', 828 'item_id' => 100, 829 'type' => 'activity_update', 830 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 831 ) ); 917 $a1 = self::factory()->activity->create( 918 array( 919 'user_id' => $u1, 920 'component' => 'activity', 921 'item_id' => 1, 922 'type' => 'activity_update', 923 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 924 ) 925 ); 926 $a2 = self::factory()->activity->create( 927 array( 928 'user_id' => $u1, 929 'component' => 'activity', 930 'item_id' => 10, 931 'type' => 'activity_update', 932 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 933 ) 934 ); 935 $a3 = self::factory()->activity->create( 936 array( 937 'user_id' => $u1, 938 'component' => 'activity', 939 'item_id' => 25, 940 'type' => 'activity_update', 941 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 942 ) 943 ); 944 $a4 = self::factory()->activity->create( 945 array( 946 'user_id' => $u1, 947 'component' => 'activity', 948 'item_id' => 100, 949 'type' => 'activity_update', 950 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 951 ) 952 ); 832 953 833 954 global $activities_template; 834 955 835 956 // greater than 836 bp_has_activities( array( 837 'filter_query' => array( 838 array( 839 'column' => 'item_id', 840 'compare' => '>', 841 'value' => 10, 957 bp_has_activities( 958 array( 959 'filter_query' => array( 960 array( 961 'column' => 'item_id', 962 'compare' => '>', 963 'value' => 10, 964 ), 842 965 ), 843 966 ) 844 ) );967 ); 845 968 846 969 // assert! … … 848 971 849 972 // greater or equal than 850 bp_has_activities( array( 851 'filter_query' => array( 852 array( 853 'column' => 'item_id', 854 'compare' => '>=', 855 'value' => 10, 973 bp_has_activities( 974 array( 975 'filter_query' => array( 976 array( 977 'column' => 'item_id', 978 'compare' => '>=', 979 'value' => 10, 980 ), 856 981 ), 857 982 ) 858 ) );983 ); 859 984 860 985 // assert! … … 862 987 863 988 // less than 864 bp_has_activities( array( 865 'filter_query' => array( 866 array( 867 'column' => 'item_id', 868 'compare' => '<', 869 'value' => 10, 989 bp_has_activities( 990 array( 991 'filter_query' => array( 992 array( 993 'column' => 'item_id', 994 'compare' => '<', 995 'value' => 10, 996 ), 870 997 ), 871 998 ) 872 ) );999 ); 873 1000 874 1001 // assert! … … 876 1003 877 1004 // less or equal than 878 bp_has_activities( array( 879 'filter_query' => array( 880 array( 881 'column' => 'item_id', 882 'compare' => '<=', 883 'value' => 10, 1005 bp_has_activities( 1006 array( 1007 'filter_query' => array( 1008 array( 1009 'column' => 'item_id', 1010 'compare' => '<=', 1011 'value' => 10, 1012 ), 884 1013 ), 885 1014 ) 886 ) );1015 ); 887 1016 888 1017 // assert! … … 890 1019 891 1020 // not equal to 892 bp_has_activities( array( 893 'filter_query' => array( 894 array( 895 'column' => 'item_id', 896 'compare' => '!=', 897 'value' => 10, 1021 bp_has_activities( 1022 array( 1023 'filter_query' => array( 1024 array( 1025 'column' => 'item_id', 1026 'compare' => '!=', 1027 'value' => 10, 1028 ), 898 1029 ), 899 1030 ) 900 ) );1031 ); 901 1032 902 1033 // assert! … … 918 1049 919 1050 // misc activity items 920 $a1 = self::factory()->activity->create( array( 921 'user_id' => $u1, 922 'component' => 'blogs', 923 'item_id' => 1, 924 'type' => 'new_blog_post', 925 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 926 ) ); 927 $a2 = self::factory()->activity->create( array( 928 'user_id' => $u1, 929 'component' => 'blogs', 930 'type' => 'new_blog_comment', 931 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 932 ) ); 933 $a3 = self::factory()->activity->create( array( 934 'user_id' => $u1, 935 'component' => 'activity', 936 'type' => 'activity_update', 937 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 938 ) ); 939 $a4 = self::factory()->activity->create( array( 940 'user_id' => $u1, 941 'component' => 'groups', 942 'item_id' => 324, 943 'type' => 'activity_update', 944 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 945 ) ); 1051 $a1 = self::factory()->activity->create( 1052 array( 1053 'user_id' => $u1, 1054 'component' => 'blogs', 1055 'item_id' => 1, 1056 'type' => 'new_blog_post', 1057 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1058 ) 1059 ); 1060 $a2 = self::factory()->activity->create( 1061 array( 1062 'user_id' => $u1, 1063 'component' => 'blogs', 1064 'type' => 'new_blog_comment', 1065 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1066 ) 1067 ); 1068 $a3 = self::factory()->activity->create( 1069 array( 1070 'user_id' => $u1, 1071 'component' => 'activity', 1072 'type' => 'activity_update', 1073 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1074 ) 1075 ); 1076 $a4 = self::factory()->activity->create( 1077 array( 1078 'user_id' => $u1, 1079 'component' => 'groups', 1080 'item_id' => 324, 1081 'type' => 'activity_update', 1082 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1083 ) 1084 ); 946 1085 947 1086 global $activities_template; 948 1087 949 1088 // REGEXP 950 bp_has_activities( array( 951 'filter_query' => array( 952 array( 953 'column' => 'type', 954 'compare' => 'REGEXP', 955 'value' => '^new_blog_', 1089 bp_has_activities( 1090 array( 1091 'filter_query' => array( 1092 array( 1093 'column' => 'type', 1094 'compare' => 'REGEXP', 1095 'value' => '^new_blog_', 1096 ), 956 1097 ), 957 1098 ) 958 ) );1099 ); 959 1100 960 1101 // assert! … … 962 1103 963 1104 // RLIKE is a synonym for REGEXP 964 bp_has_activities( array( 965 'filter_query' => array( 966 array( 967 'column' => 'type', 968 'compare' => 'RLIKE', 969 'value' => '^new_blog_', 1105 bp_has_activities( 1106 array( 1107 'filter_query' => array( 1108 array( 1109 'column' => 'type', 1110 'compare' => 'RLIKE', 1111 'value' => '^new_blog_', 1112 ), 970 1113 ), 971 1114 ) 972 ) );1115 ); 973 1116 974 1117 // assert! … … 976 1119 977 1120 // NOT REGEXP 978 bp_has_activities( array( 979 'filter_query' => array( 980 array( 981 'column' => 'type', 982 'compare' => 'NOT REGEXP', 983 'value' => '^new_blog_', 1121 bp_has_activities( 1122 array( 1123 'filter_query' => array( 1124 array( 1125 'column' => 'type', 1126 'compare' => 'NOT REGEXP', 1127 'value' => '^new_blog_', 1128 ), 984 1129 ), 985 1130 ) 986 ) );1131 ); 987 1132 988 1133 // assert! … … 999 1144 public function test_bp_has_activities_private_group_home_scope() { 1000 1145 global $activities_template; 1001 $bp = buddypress();1002 $reset_current_group = $bp->groups->current_group;1146 $bp = buddypress(); 1147 $reset_current_group = $bp->groups->current_group; 1003 1148 $reset_current_action = $bp->current_action; 1004 1149 … … 1009 1154 self::set_current_user( $u1 ); 1010 1155 1011 $g = self::factory()->group->create( array( 1012 'status' => 'private', 1013 ) ); 1156 $g = self::factory()->group->create( 1157 array( 1158 'status' => 'private', 1159 ) 1160 ); 1014 1161 1015 1162 groups_join_group( $g, $u2 ); 1016 1163 groups_join_group( $g, $u3 ); 1017 1164 1018 $a1 = self::factory()->activity->create( array( 1019 'component' => $bp->groups->id, 1020 'item_id' => $g, 1021 'type' => 'activity_update', 1022 'user_id' => $u2, 1023 'content' => 'foo bar', 1024 ) ); 1025 1026 $a2 = self::factory()->activity->create( array( 1027 'component' => $bp->groups->id, 1028 'item_id' => $g, 1029 'type' => 'activity_update', 1030 'user_id' => $u3, 1031 'content' => 'bar foo', 1032 ) ); 1165 $a1 = self::factory()->activity->create( 1166 array( 1167 'component' => $bp->groups->id, 1168 'item_id' => $g, 1169 'type' => 'activity_update', 1170 'user_id' => $u2, 1171 'content' => 'foo bar', 1172 ) 1173 ); 1174 1175 $a2 = self::factory()->activity->create( 1176 array( 1177 'component' => $bp->groups->id, 1178 'item_id' => $g, 1179 'type' => 'activity_update', 1180 'user_id' => $u3, 1181 'content' => 'bar foo', 1182 ) 1183 ); 1033 1184 1034 1185 $bp->groups->current_group = groups_get_group( $g ); … … 1042 1193 1043 1194 // clean up! 1044 $activities_template = null;1195 $activities_template = null; 1045 1196 $bp->groups->current_group = $reset_current_group; 1046 $bp->current_action = $reset_current_action;1197 $bp->current_action = $reset_current_action; 1047 1198 } 1048 1199 … … 1053 1204 public function test_bp_has_activities_hidden_group_home_scope() { 1054 1205 global $activities_template; 1055 $bp = buddypress();1056 $reset_current_group = $bp->groups->current_group;1206 $bp = buddypress(); 1207 $reset_current_group = $bp->groups->current_group; 1057 1208 $reset_current_action = $bp->current_action; 1058 1209 … … 1063 1214 self::set_current_user( $u1 ); 1064 1215 1065 $g = self::factory()->group->create( array( 1066 'status' => 'hidden', 1067 ) ); 1216 $g = self::factory()->group->create( 1217 array( 1218 'status' => 'hidden', 1219 ) 1220 ); 1068 1221 1069 1222 groups_join_group( $g, $u2 ); 1070 1223 groups_join_group( $g, $u3 ); 1071 1224 1072 $a1 = self::factory()->activity->create( array( 1073 'component' => $bp->groups->id, 1074 'item_id' => $g, 1075 'type' => 'activity_update', 1076 'user_id' => $u2, 1077 'content' => 'foo bar', 1078 ) ); 1079 1080 $a2 = self::factory()->activity->create( array( 1081 'component' => $bp->groups->id, 1082 'item_id' => $g, 1083 'type' => 'activity_update', 1084 'user_id' => $u3, 1085 'content' => 'bar foo', 1086 ) ); 1225 $a1 = self::factory()->activity->create( 1226 array( 1227 'component' => $bp->groups->id, 1228 'item_id' => $g, 1229 'type' => 'activity_update', 1230 'user_id' => $u2, 1231 'content' => 'foo bar', 1232 ) 1233 ); 1234 1235 $a2 = self::factory()->activity->create( 1236 array( 1237 'component' => $bp->groups->id, 1238 'item_id' => $g, 1239 'type' => 'activity_update', 1240 'user_id' => $u3, 1241 'content' => 'bar foo', 1242 ) 1243 ); 1087 1244 1088 1245 $bp->groups->current_group = groups_get_group( $g ); … … 1096 1253 1097 1254 // clean up! 1098 $activities_template = null;1255 $activities_template = null; 1099 1256 $bp->groups->current_group = $reset_current_group; 1100 $bp->current_action = $reset_current_action;1257 $bp->current_action = $reset_current_action; 1101 1258 } 1102 1259 … … 1110 1267 1111 1268 global $activities_template; 1112 bp_has_activities( array( 1113 'meta_query' => array( 1114 array( 1115 'key' => 'foo', 1116 'value' => 'bar', 1269 bp_has_activities( 1270 array( 1271 'meta_query' => array( 1272 array( 1273 'key' => 'foo', 1274 'value' => 'bar', 1275 ), 1117 1276 ), 1118 ) ,1119 ) );1277 ) 1278 ); 1120 1279 1121 1280 $ids = wp_list_pluck( $activities_template->activities, 'id' ); … … 1129 1288 public function test_bp_has_activities_with_display_comments_false() { 1130 1289 $now = time(); 1131 $a1 = self::factory()->activity->create( array( 1132 'content' => 'Life Rules', 1133 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1134 ) ); 1135 $a2 = self::factory()->activity->create( array( 1136 'content' => 'Life Drools', 1137 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1138 ) ); 1139 $a3 = bp_activity_new_comment( array( 1140 'activity_id' => $a1, 1141 'content' => 'Candy is good', 1142 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1143 ) ); 1144 1145 global $activities_template; 1146 bp_has_activities( array( 1147 'display_comments' => false, 1148 ) ); 1290 $a1 = self::factory()->activity->create( 1291 array( 1292 'content' => 'Life Rules', 1293 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1294 ) 1295 ); 1296 $a2 = self::factory()->activity->create( 1297 array( 1298 'content' => 'Life Drools', 1299 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1300 ) 1301 ); 1302 $a3 = bp_activity_new_comment( 1303 array( 1304 'activity_id' => $a1, 1305 'content' => 'Candy is good', 1306 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1307 ) 1308 ); 1309 1310 global $activities_template; 1311 bp_has_activities( 1312 array( 1313 'display_comments' => false, 1314 ) 1315 ); 1149 1316 $ids = wp_list_pluck( $activities_template->activities, 'id' ); 1150 1317 1151 1318 $this->assertEquals( array( $a1, $a2 ), wp_parse_id_list( $ids ) ); 1152 1153 1319 } 1154 1320 … … 1159 1325 public function test_bp_has_activities_with_display_comments_0() { 1160 1326 $now = time(); 1161 $a1 = self::factory()->activity->create( array( 1162 'content' => 'Life Rules', 1163 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1164 ) ); 1165 $a2 = self::factory()->activity->create( array( 1166 'content' => 'Life Drools', 1167 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1168 ) ); 1169 $a3 = bp_activity_new_comment( array( 1170 'activity_id' => $a1, 1171 'content' => 'Candy is good', 1172 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1173 ) ); 1174 1175 global $activities_template; 1176 bp_has_activities( array( 1177 'display_comments' => 0, 1178 ) ); 1327 $a1 = self::factory()->activity->create( 1328 array( 1329 'content' => 'Life Rules', 1330 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1331 ) 1332 ); 1333 $a2 = self::factory()->activity->create( 1334 array( 1335 'content' => 'Life Drools', 1336 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1337 ) 1338 ); 1339 $a3 = bp_activity_new_comment( 1340 array( 1341 'activity_id' => $a1, 1342 'content' => 'Candy is good', 1343 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1344 ) 1345 ); 1346 1347 global $activities_template; 1348 bp_has_activities( 1349 array( 1350 'display_comments' => 0, 1351 ) 1352 ); 1179 1353 $ids = wp_list_pluck( $activities_template->activities, 'id' ); 1180 1354 1181 1355 $this->assertEquals( array( $a1, $a2 ), wp_parse_id_list( $ids ) ); 1182 1183 1356 } 1184 1357 … … 1189 1362 public function test_bp_has_activities_with_display_comments_0_querystring() { 1190 1363 $now = time(); 1191 $a1 = self::factory()->activity->create( array( 1192 'content' => 'Life Rules', 1193 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1194 ) ); 1195 $a2 = self::factory()->activity->create( array( 1196 'content' => 'Life Drools', 1197 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1198 ) ); 1199 $a3 = bp_activity_new_comment( array( 1200 'activity_id' => $a1, 1201 'content' => 'Candy is good', 1202 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1203 ) ); 1364 $a1 = self::factory()->activity->create( 1365 array( 1366 'content' => 'Life Rules', 1367 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1368 ) 1369 ); 1370 $a2 = self::factory()->activity->create( 1371 array( 1372 'content' => 'Life Drools', 1373 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1374 ) 1375 ); 1376 $a3 = bp_activity_new_comment( 1377 array( 1378 'activity_id' => $a1, 1379 'content' => 'Candy is good', 1380 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1381 ) 1382 ); 1204 1383 1205 1384 global $activities_template; … … 1208 1387 1209 1388 $this->assertEquals( array( $a1, $a2 ), $ids ); 1210 1211 1389 } 1212 1390 … … 1217 1395 public function test_bp_has_activities_with_display_comments_none_querystring() { 1218 1396 $now = time(); 1219 $a1 = self::factory()->activity->create( array( 1220 'content' => 'Life Rules', 1221 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1222 ) ); 1223 $a2 = self::factory()->activity->create( array( 1224 'content' => 'Life Drools', 1225 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1226 ) ); 1227 $a3 = bp_activity_new_comment( array( 1228 'activity_id' => $a1, 1229 'content' => 'Candy is good', 1230 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1231 ) ); 1397 $a1 = self::factory()->activity->create( 1398 array( 1399 'content' => 'Life Rules', 1400 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1401 ) 1402 ); 1403 $a2 = self::factory()->activity->create( 1404 array( 1405 'content' => 'Life Drools', 1406 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1407 ) 1408 ); 1409 $a3 = bp_activity_new_comment( 1410 array( 1411 'activity_id' => $a1, 1412 'content' => 'Candy is good', 1413 'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ), 1414 ) 1415 ); 1232 1416 1233 1417 global $activities_template; … … 1236 1420 1237 1421 $this->assertEquals( array( $a1, $a2 ), $ids ); 1238 1239 1422 } 1240 1423 … … 1245 1428 public function test_bp_has_activities_with_update_meta_cache_false() { 1246 1429 $now = time(); 1247 $a1 = self::factory()->activity->create( array( 1248 'content' => 'Life Rules', 1249 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1250 ) ); 1251 $a2 = self::factory()->activity->create( array( 1252 'content' => 'Life Drools', 1253 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1254 ) ); 1430 $a1 = self::factory()->activity->create( 1431 array( 1432 'content' => 'Life Rules', 1433 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1434 ) 1435 ); 1436 $a2 = self::factory()->activity->create( 1437 array( 1438 'content' => 'Life Drools', 1439 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1440 ) 1441 ); 1255 1442 1256 1443 bp_activity_add_meta( $a1, 'foo', 'bar' ); … … 1258 1445 1259 1446 // prime 1260 bp_has_activities( array( 1261 'update_meta_cache' => false, 1262 ) ); 1447 bp_has_activities( 1448 array( 1449 'update_meta_cache' => false, 1450 ) 1451 ); 1263 1452 1264 1453 $this->assertFalse( wp_cache_get( $a1, 'activity_meta' ) ); … … 1272 1461 public function test_bp_has_activities_with_update_meta_cache_true() { 1273 1462 $now = time(); 1274 $a1 = self::factory()->activity->create( array( 1275 'content' => 'Life Rules', 1276 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1277 ) ); 1278 $a2 = self::factory()->activity->create( array( 1279 'content' => 'Life Drools', 1280 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1281 ) ); 1463 $a1 = self::factory()->activity->create( 1464 array( 1465 'content' => 'Life Rules', 1466 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1467 ) 1468 ); 1469 $a2 = self::factory()->activity->create( 1470 array( 1471 'content' => 'Life Drools', 1472 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1473 ) 1474 ); 1282 1475 1283 1476 bp_activity_add_meta( $a1, 'foo', 'bar' ); … … 1285 1478 1286 1479 // prime 1287 bp_has_activities( array( 1288 'update_meta_cache' => true, 1289 ) ); 1480 bp_has_activities( 1481 array( 1482 'update_meta_cache' => true, 1483 ) 1484 ); 1290 1485 1291 1486 $this->assertNotEmpty( wp_cache_get( $a1, 'activity_meta' ) ); … … 1303 1498 1304 1499 $now = time(); 1305 $a1 = self::factory()->activity->create( array( 1306 'content' => 'Life Rules', 1307 'component' => 'blogs', 1308 'type' => 'new_blog_post', 1309 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1310 'user_id' => $u, 1311 ) ); 1312 $a2 = self::factory()->activity->create( array( 1313 'content' => 'Life Drools', 1314 'component' => 'blogs', 1315 'type' => 'new_blog_comment', 1316 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1317 'user_id' => $u, 1318 ) ); 1500 $a1 = self::factory()->activity->create( 1501 array( 1502 'content' => 'Life Rules', 1503 'component' => 'blogs', 1504 'type' => 'new_blog_post', 1505 'recorded_time' => date( 'Y-m-d H:i:s', $now ), 1506 'user_id' => $u, 1507 ) 1508 ); 1509 $a2 = self::factory()->activity->create( 1510 array( 1511 'content' => 'Life Drools', 1512 'component' => 'blogs', 1513 'type' => 'new_blog_comment', 1514 'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ), 1515 'user_id' => $u, 1516 ) 1517 ); 1319 1518 1320 1519 // This one will show up in the stream because it's a comment 1321 1520 // on a blog post 1322 $a3 = bp_activity_new_comment( array( 1323 'activity_id' => $a1, 1324 'content' => 'Candy is good', 1325 'recorded_time' => date( 'Y-m-d H:i:s', $now - 200 ), 1326 'user_id' => $u, 1327 ) ); 1328 1329 $a4 = self::factory()->activity->create( array( 1330 'content' => 'Life Rulez', 1331 'component' => 'activity', 1332 'type' => 'activity_update', 1333 'recorded_time' => date( 'Y-m-d H:i:s', $now - 300 ), 1334 'user_id' => $u, 1335 ) ); 1521 $a3 = bp_activity_new_comment( 1522 array( 1523 'activity_id' => $a1, 1524 'content' => 'Candy is good', 1525 'recorded_time' => date( 'Y-m-d H:i:s', $now - 200 ), 1526 'user_id' => $u, 1527 ) 1528 ); 1529 1530 $a4 = self::factory()->activity->create( 1531 array( 1532 'content' => 'Life Rulez', 1533 'component' => 'activity', 1534 'type' => 'activity_update', 1535 'recorded_time' => date( 'Y-m-d H:i:s', $now - 300 ), 1536 'user_id' => $u, 1537 ) 1538 ); 1336 1539 1337 1540 // This one should not show up in the stream because it's a 1338 1541 // comment on an activity item 1339 $a5 = bp_activity_new_comment( array( 1340 'activity_id' => $a4, 1341 'content' => 'Candy is great', 1342 'recorded_time' => date( 'Y-m-d H:i:s', $now - 400 ), 1343 'user_id' => $u, 1344 ) ); 1542 $a5 = bp_activity_new_comment( 1543 array( 1544 'activity_id' => $a4, 1545 'content' => 'Candy is great', 1546 'recorded_time' => date( 'Y-m-d H:i:s', $now - 400 ), 1547 'user_id' => $u, 1548 ) 1549 ); 1345 1550 global $activities_template; 1346 1551 1347 1552 // prime 1348 bp_has_activities( array( 1349 'component' => 'blogs', 1350 'action' => 'new_blog_comment', 1351 ) ); 1553 bp_has_activities( 1554 array( 1555 'component' => 'blogs', 1556 'action' => 'new_blog_comment', 1557 ) 1558 ); 1352 1559 1353 1560 $this->assertEquals( array( $a3, $a2 ), wp_parse_id_list( wp_list_pluck( $activities_template->activities, 'id' ) ) ); … … 1370 1577 // Fake the global 1371 1578 global $activities_template; 1372 $activities_template = new stdClass;1373 $activities_template->activity = new stdClass;1374 $activities_template->activity->current_comment = new stdClass ;1375 1376 $comment = new stdClass;1579 $activities_template = new stdClass(); 1580 $activities_template->activity = new stdClass(); 1581 $activities_template->activity->current_comment = new stdClass(); 1582 1583 $comment = new stdClass(); 1377 1584 $comment->item_id = 4; 1378 1585 … … 1407 1614 // Fake the global 1408 1615 global $activities_template; 1409 $activities_template = new stdClass;1410 $activities_template->activity = new stdClass;1411 $activities_template->activity->current_comment = new stdClass ;1412 1413 $comment = new stdClass;1616 $activities_template = new stdClass(); 1617 $activities_template->activity = new stdClass(); 1618 $activities_template->activity->current_comment = new stdClass(); 1619 1620 $comment = new stdClass(); 1414 1621 $comment->item_id = 4; 1415 1622 … … 1433 1640 $reset_activities_template = $activities_template; 1434 1641 1435 $activities_template = new stdClass;1642 $activities_template = new stdClass(); 1436 1643 $activities_template->disable_blogforum_replies = true; 1437 $activities_template->activity = (object) array( 'type' => 'activity_comment' );1644 $activities_template->activity = (object) array( 'type' => 'activity_comment' ); 1438 1645 1439 1646 $this->assertFalse( bp_activity_can_comment(), 'bp_activity_can_comment() should return false if the activity type is activity_comment' ); … … 1443 1650 'new_blog_comment', 1444 1651 'new_forum_topic', 1445 'new_forum_post' 1652 'new_forum_post', 1446 1653 ); 1447 1654 … … 1473 1680 1474 1681 $reset_activities_template = $activities_template; 1475 $reset_activity_track = $bp->activity->track;1476 1477 $activities_template = new stdClass;1682 $reset_activity_track = $bp->activity->track; 1683 1684 $activities_template = new stdClass(); 1478 1685 $activities_template->disable_blogforum_replies = true; 1479 1686 1480 register_post_type( 'foo', array( 1481 'label' => 'foo', 1482 'public' => true, 1483 'supports' => array( 'buddypress-activity' ), 1484 ) ); 1687 register_post_type( 1688 'foo', 1689 array( 1690 'label' => 'foo', 1691 'public' => true, 1692 'supports' => array( 'buddypress-activity' ), 1693 ) 1694 ); 1485 1695 1486 1696 $bp->activity->track = bp_activity_get_post_types_tracking_args(); … … 1496 1706 $this->assertFalse( bp_activity_can_comment(), 'If post type support comments, a post type activity cannot be commented' ); 1497 1707 1498 $bp_activity_support = (array) $bp->activity->track['new_foo'];1708 $bp_activity_support = (array) $bp->activity->track['new_foo']; 1499 1709 $bp_activity_support['activity_comment'] = true; 1500 1710 … … 1538 1748 $args = array( 1539 1749 'count_total' => false, 1540 'per_page' => 2,1750 'per_page' => 2, 1541 1751 ); 1542 1752 … … 1579 1789 $args = array( 1580 1790 'count_total' => 'count_query', 1581 'per_page' => 2,1791 'per_page' => 2, 1582 1792 ); 1583 1793 … … 1601 1811 1602 1812 $a1 = self::factory()->activity->create(); 1603 $a2 = self::factory()->activity->create( array( 1604 'recorded_time' => '2001-01-01 12:00' 1605 ) ); 1606 $a3 = self::factory()->activity->create( array( 1607 'recorded_time' => '2005-01-01 12:00' 1608 ) ); 1609 1610 global $activities_template; 1611 bp_has_activities( array( 1612 'date_query' => array( array( 1613 'after' => '1 day ago' 1614 ) ) 1615 ) ); 1813 $a2 = self::factory()->activity->create( 1814 array( 1815 'recorded_time' => '2001-01-01 12:00', 1816 ) 1817 ); 1818 $a3 = self::factory()->activity->create( 1819 array( 1820 'recorded_time' => '2005-01-01 12:00', 1821 ) 1822 ); 1823 1824 global $activities_template; 1825 bp_has_activities( 1826 array( 1827 'date_query' => array( 1828 array( 1829 'after' => '1 day ago', 1830 ), 1831 ), 1832 ) 1833 ); 1616 1834 1617 1835 $ids = wp_list_pluck( $activities_template->activities, 'id' ); … … 1624 1842 */ 1625 1843 public function test_bp_activity_template_should_give_precedence_to_acpage_URL_param() { 1626 $request = $_REQUEST;1844 $request = $_REQUEST; 1627 1845 $_REQUEST['acpage'] = '5'; 1628 1846 1629 $at = new BP_Activity_Template( array( 1630 'page' => 8, 1631 ) ); 1847 $at = new BP_Activity_Template( 1848 array( 1849 'page' => 8, 1850 ) 1851 ); 1632 1852 1633 1853 $this->assertEquals( 5, $at->pag_page ); … … 1641 1861 */ 1642 1862 public function test_bp_activity_template_should_reset_0_pag_page_URL_param_to_default_pag_page_value() { 1643 $request = $_REQUEST;1863 $request = $_REQUEST; 1644 1864 $_REQUEST['acpage'] = '0'; 1645 1865 1646 $at = new BP_Activity_Template( array( 1647 'page' => 8, 1648 ) ); 1866 $at = new BP_Activity_Template( 1867 array( 1868 'page' => 8, 1869 ) 1870 ); 1649 1871 1650 1872 $this->assertEquals( 8, $at->pag_page ); … … 1658 1880 */ 1659 1881 public function test_bp_activity_template_should_give_precedence_to_num_URL_param() { 1660 $request = $_REQUEST;1882 $request = $_REQUEST; 1661 1883 $_REQUEST['num'] = '14'; 1662 1884 1663 $at = new BP_Activity_Template( array( 1664 'per_page' => 13, 1665 ) ); 1885 $at = new BP_Activity_Template( 1886 array( 1887 'per_page' => 13, 1888 ) 1889 ); 1666 1890 1667 1891 $this->assertEquals( 14, $at->pag_num ); … … 1675 1899 */ 1676 1900 public function test_bp_activity_template_should_reset_0_pag_num_URL_param_to_default_pag_num_value() { 1677 $request = $_REQUEST;1901 $request = $_REQUEST; 1678 1902 $_REQUEST['num'] = '0'; 1679 1903 1680 $at = new BP_Activity_Template( array( 1681 'per_page' => 13, 1682 ) ); 1904 $at = new BP_Activity_Template( 1905 array( 1906 'per_page' => 13, 1907 ) 1908 ); 1683 1909 1684 1910 $this->assertEquals( 13, $at->pag_num ); -
trunk/tests/phpunit/testcases/blogs/template.php
r13184 r14026 19 19 $this->assertEquals( bp_core_get_last_activity( $time, __( 'Active %s', 'buddypress' ) ), bp_get_blog_last_active() ); 20 20 21 $blogs_template ->blog= null;21 $blogs_template = null; 22 22 } 23 23 … … 36 36 $this->assertEquals( bp_core_get_last_activity( $time, __( 'Active %s', 'buddypress' ) ), bp_get_blog_last_active( array( 'active_format' => true, ) ) ); 37 37 38 $blogs_template ->blog= null;38 $blogs_template = null; 39 39 } 40 40 … … 53 53 $this->assertEquals( bp_core_time_since( $time ), bp_get_blog_last_active( array( 'active_format' => false, ) ) ); 54 54 55 $blogs_template ->blog= null;55 $blogs_template = null; 56 56 } 57 57 … … 78 78 $this->assertSame( sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="foo">bar</a>' ), bp_get_blog_latest_post() ); 79 79 80 $blogs_template ->blog= null;80 $blogs_template = null; 81 81 } 82 82 … … 96 96 $this->assertSame( sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="foo">bar</a>' ), bp_get_blog_latest_post( array( 'latest_format' => true, ) ) ); 97 97 98 $blogs_template ->blog= null;98 $blogs_template = null; 99 99 } 100 100 … … 114 114 $this->assertSame( '<a href="foo">bar</a>', bp_get_blog_latest_post( array( 'latest_format' => false, ) ) ); 115 115 116 $blogs_template ->blog= null;116 $blogs_template = null; 117 117 } 118 118 -
trunk/tests/phpunit/testcases/core/class-bp-component.php
r13422 r14026 1 1 <?php 2 2 3 include_once BP_TESTS_DIR . '/assets/bp-rest-api-controllers.php';4 3 include_once BP_TESTS_DIR . '/assets/class-bptest-component.php'; 5 4 … … 9 8 */ 10 9 class BP_Tests_BP_Component_TestCases extends BP_UnitTestCase { 11 public function set_up() {12 parent::set_up();13 14 $bp = buddypress();15 $bp->unit_test_rest = new stdClass;16 $bp->unit_test_rest->controllers = array();17 }18 19 public function remove_controller( $controllers ) {20 return array_diff( $controllers, array( 'BP_REST_Members_Endpoint' ) );21 }22 23 public function add_controller( $controllers ) {24 return array_merge( $controllers, array( 'Foo_Bar' ) );25 }26 27 public function test_rest_api_init_for_members_component() {28 $bp_members = new BP_Members_Component();29 $bp = buddypress();30 31 $bp_members->rest_api_init();32 33 $this->assertSame( $bp->unit_test_rest->controllers, array(34 'BP_REST_Members_Endpoint',35 'BP_REST_Attachments_Member_Avatar_Endpoint',36 'BP_REST_Attachments_Member_Cover_Endpoint',37 ) );38 }39 40 public function test_rest_api_init_for_members_component_can_remove_controller() {41 $bp_members = new BP_Members_Component();42 $bp = buddypress();43 44 add_filter( 'bp_members_rest_api_controllers', array( $this, 'remove_controller' ) );45 46 $bp_members->rest_api_init();47 48 remove_filter( 'bp_members_rest_api_controllers', array( $this, 'remove_controller' ) );49 50 $this->assertSame( $bp->unit_test_rest->controllers, array(51 'BP_REST_Attachments_Member_Avatar_Endpoint',52 'BP_REST_Attachments_Member_Cover_Endpoint',53 ) );54 }55 56 public function test_rest_api_init_for_members_component_cannot_add_controller() {57 $bp_members = new BP_Members_Component();58 $bp = buddypress();59 60 add_filter( 'bp_members_rest_api_controllers', array( $this, 'add_controller' ) );61 62 $bp_members->rest_api_init();63 64 remove_filter( 'bp_members_rest_api_controllers', array( $this, 'add_controller' ) );65 66 $this->assertSame( $bp->unit_test_rest->controllers, array(67 'BP_REST_Members_Endpoint',68 'BP_REST_Attachments_Member_Avatar_Endpoint',69 'BP_REST_Attachments_Member_Cover_Endpoint',70 ) );71 }72 10 73 11 /** -
trunk/tests/phpunit/testcases/core/invitations.php
r13990 r14026 1 1 <?php 2 2 3 include_once BP_TESTS_DIR . 'assets/invitations-extensions.php';3 require_once BP_TESTS_DIR . 'assets/invitations-extensions.php'; 4 4 5 5 /** … … 7 7 * @group invitations 8 8 */ 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 'user_id'=> $u3,27 'inviter_id'=> $u1,28 'item_id'=> 1,29 'send_invite'=> 'sent',30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 9 class BP_Tests_Invitations extends BP_UnitTestCase { 10 11 /** 12 * @ticket BP8552 13 * @group cache 14 */ 15 public function test_invitation_query_with_ids_cache_results() { 16 global $wpdb; 17 18 $u1 = self::factory()->user->create(); 19 $u2 = self::factory()->user->create(); 20 $u3 = self::factory()->user->create(); 21 22 $invites_class = new BPTest_Invitation_Manager_Extension(); 23 24 // Create a couple of invitations. 25 $invite_args = array( 26 'user_id' => $u3, 27 'inviter_id' => $u1, 28 'item_id' => 1, 29 'send_invite' => 'sent', 30 ); 31 32 $invites_class->add_invitation( $invite_args ); 33 34 $invite_args['inviter_id'] = $u2; 35 36 $invites_class->add_invitation( $invite_args ); 37 38 $wpdb->num_queries = 0; 39 40 $first_query = BP_Invitation::get( 41 array( 42 'cache_results' => true, 43 'fields' => 'ids', 44 ) 45 ); 46 47 $queries_before = get_num_queries(); 48 49 $second_query = BP_Invitation::get( 50 array( 51 'cache_results' => false, 52 'fields' => 'ids', 53 ) 54 ); 55 56 $queries_after = get_num_queries(); 57 58 $this->assertNotSame( $queries_before, $queries_after, 'Assert that queries are run' ); 59 $this->assertSame( 2, $queries_after, 'Assert that the uncached query was run' ); 60 $this->assertSameSets( $first_query, $second_query, 'Results of the query are expected to match.' ); 61 } 62 63 /** 64 * @ticket BP8552 65 * @group cache 66 */ 67 public function test_invitation_query_with_all_cache_results() { 68 global $wpdb; 69 70 $u1 = self::factory()->user->create(); 71 $u2 = self::factory()->user->create(); 72 $u3 = self::factory()->user->create(); 73 74 $invites_class = new BPTest_Invitation_Manager_Extension(); 75 76 // Create a couple of invitations. 77 $invite_args = array( 78 'user_id' => $u3, 79 'inviter_id' => $u1, 80 'item_id' => 1, 81 'send_invite' => 'sent', 82 ); 83 84 $invites_class->add_invitation( $invite_args ); 85 86 $invite_args['inviter_id'] = $u2; 87 88 $invites_class->add_invitation( $invite_args ); 89 90 $wpdb->num_queries = 0; 91 92 $first_query = BP_Invitation::get( 93 array( 'cache_results' => true ) 94 ); 95 96 $queries_before = get_num_queries(); 97 98 $second_query = BP_Invitation::get( 99 array( 'cache_results' => false ) 100 ); 101 102 $queries_after = get_num_queries(); 103 104 $this->assertNotSame( $queries_before, $queries_after, 'Assert that queries are run' ); 105 $this->assertSame( 3, $queries_after, 'Assert that the uncached query was run' ); 106 $this->assertEquals( $first_query, $second_query, 'Results of the query are expected to match.' ); 107 } 108 108 109 109 public function test_bp_invitations_add_invitation_vanilla() { … … 118 118 119 119 // Create a couple of invitations. 120 $invite_args = array(121 'user_id' 122 'inviter_id' 123 'item_id' 124 'send_invite' 125 ); 126 $i1 = $invites_class->add_invitation( $invite_args );120 $invite_args = array( 121 'user_id' => $u3, 122 'inviter_id' => $u1, 123 'item_id' => 1, 124 'send_invite' => 'sent', 125 ); 126 $i1 = $invites_class->add_invitation( $invite_args ); 127 127 $invite_args['inviter_id'] = $u2; 128 $i2 = $invites_class->add_invitation( $invite_args );129 130 $get_invites = array( 131 'user_id' 132 'fields' 133 ); 134 $invites = $invites_class->get_invitations( $get_invites );128 $i2 = $invites_class->add_invitation( $invite_args ); 129 130 $get_invites = array( 131 'user_id' => $u3, 132 'fields' => 'ids', 133 ); 134 $invites = $invites_class->get_invitations( $get_invites ); 135 135 $this->assertEqualSets( array( $i1, $i2 ), $invites ); 136 136 … … 149 149 // Create an invitation. 150 150 $invite_args = array( 151 'user_id' 152 'inviter_id' 153 'item_id' 154 'send_invite' 155 ); 156 $i1 = $invites_class->add_invitation( $invite_args );151 'user_id' => $u2, 152 'inviter_id' => $u1, 153 'item_id' => 1, 154 'send_invite' => 'sent', 155 ); 156 $i1 = $invites_class->add_invitation( $invite_args ); 157 157 // Attempt to create a duplicate. Should return existing invite. 158 158 $i2 = $invites_class->add_invitation( $invite_args ); … … 168 168 $u2 = self::factory()->user->create(); 169 169 $u3 = self::factory()->user->create(); 170 self::set_current_user( $u1 ); 171 172 $invites_class = new BPTest_Invitation_Manager_Extension(); 173 174 // Create an invitation. 175 $invite_args = array( 176 'user_id' => $u3, 177 'inviter_id' => $u1, 178 'item_id' => 1, 179 'send_invite' => 'sent', 180 ); 181 $i1 = $invites_class->add_invitation( $invite_args ); 170 171 self::set_current_user( $u1 ); 172 173 $invites_class = new BPTest_Invitation_Manager_Extension(); 174 175 // Create an invitation. 176 $i1 = $invites_class->add_invitation( 177 array( 178 'user_id' => $u3, 179 'inviter_id' => $u1, 180 'item_id' => 1, 181 'send_invite' => 'sent', 182 ) 183 ); 184 185 $this->assertIsInt( $i1, 'Invitation ID is not an integer.' ); 186 187 // Create a request. 188 $invites_class->add_request( 189 array( 190 'user_id' => $u3, 191 'item_id' => 1, 192 ) 193 ); 194 195 $get_invites = array( 196 'user_id' => $u3, 197 'accepted' => 'accepted', 198 ); 199 200 $invites = $invites_class->get_invitations( $get_invites ); 201 $invite_ids = wp_list_pluck( $invites, 'id' ); 202 203 $this->assertNotEmpty( $invite_ids ); 204 $this->assertEqualSets( array( $i1 ), $invite_ids ); 205 206 self::set_current_user( $old_current_user ); 207 } 208 209 public function test_bp_invitations_add_invitation_unsent_invite_plus_request_should_not_accept() { 210 $old_current_user = get_current_user_id(); 211 212 $u1 = self::factory()->user->create(); 213 $u2 = self::factory()->user->create(); 214 $u3 = self::factory()->user->create(); 215 self::set_current_user( $u1 ); 216 217 $invites_class = new BPTest_Invitation_Manager_Extension(); 218 219 // Create an invitation. 220 $invite_args = array( 221 'user_id' => $u3, 222 'inviter_id' => $u1, 223 'item_id' => 1, 224 'send_invite' => 0, 225 ); 226 $i1 = $invites_class->add_invitation( $invite_args ); 182 227 183 228 // Create a request. 184 229 $request_args = array( 185 'user_id' 186 'item_id' 187 ); 188 $r1 = $invites_class->add_request( $request_args );189 190 $get_invites = array( 191 'user_id' 192 'accepted' => 'accepted'193 ); 194 $invites = $invites_class->get_invitations( $get_invites );195 $this->assertEqualSets( array( $i1), wp_list_pluck( $invites, 'id' ) );196 197 self::set_current_user( $old_current_user ); 198 } 199 200 public function test_bp_invitations_add_invitation_unsent_invite_plus_request_ should_not_accept() {201 $old_current_user = get_current_user_id(); 202 203 $u1 = self::factory()->user->create(); 204 $u2 = self::factory()->user->create(); 205 $u3 = self::factory()->user->create(); 206 self::set_current_user( $u1 ); 207 208 $invites_class = new BPTest_Invitation_Manager_Extension(); 209 210 // Create an invitation. 211 $invite_args = array( 212 'user_id' 213 'inviter_id' 214 'item_id' 215 'send_invite' 216 ); 217 $i1 = $invites_class->add_invitation( $invite_args );230 'user_id' => $u3, 231 'item_id' => 1, 232 ); 233 $r1 = $invites_class->add_request( $request_args ); 234 235 $get_invites = array( 236 'user_id' => $u3, 237 'accepted' => 'accepted', 238 ); 239 $invites = $invites_class->get_invitations( $get_invites ); 240 $this->assertEqualSets( array(), wp_list_pluck( $invites, 'id' ) ); 241 242 self::set_current_user( $old_current_user ); 243 } 244 245 public function test_bp_invitations_add_invitation_unsent_invite_plus_request_then_send_invite_should_accept() { 246 $old_current_user = get_current_user_id(); 247 248 $u1 = self::factory()->user->create(); 249 $u2 = self::factory()->user->create(); 250 $u3 = self::factory()->user->create(); 251 self::set_current_user( $u1 ); 252 253 $invites_class = new BPTest_Invitation_Manager_Extension(); 254 255 // Create an invitation. 256 $invite_args = array( 257 'user_id' => $u3, 258 'inviter_id' => $u1, 259 'item_id' => 1, 260 'send_invite' => 0, 261 ); 262 $i1 = $invites_class->add_invitation( $invite_args ); 218 263 219 264 // Create a request. 220 265 $request_args = array( 221 'user_id' => $u3, 222 'item_id' => 1, 223 ); 224 $r1 = $invites_class->add_request( $request_args ); 225 226 $get_invites = array( 227 'user_id' => $u3, 228 'accepted' => 'accepted' 229 ); 230 $invites = $invites_class->get_invitations( $get_invites ); 231 $this->assertEqualSets( array(), wp_list_pluck( $invites, 'id' ) ); 232 233 self::set_current_user( $old_current_user ); 234 } 235 236 public function test_bp_invitations_add_invitation_unsent_invite_plus_request_then_send_invite_should_accept() { 237 $old_current_user = get_current_user_id(); 238 239 $u1 = self::factory()->user->create(); 240 $u2 = self::factory()->user->create(); 241 $u3 = self::factory()->user->create(); 242 self::set_current_user( $u1 ); 243 244 $invites_class = new BPTest_Invitation_Manager_Extension(); 245 246 // Create an invitation. 247 $invite_args = array( 248 'user_id' => $u3, 249 'inviter_id' => $u1, 250 'item_id' => 1, 251 'send_invite' => 0, 252 ); 253 $i1 = $invites_class->add_invitation( $invite_args ); 266 'user_id' => $u3, 267 'item_id' => 1, 268 ); 269 $r1 = $invites_class->add_request( $request_args ); 270 271 $invites_class->send_invitation_by_id( $i1 ); 272 273 // Check that both the request and invitation are marked 'accepted'. 274 $get_invites = array( 275 'user_id' => $u3, 276 'type' => 'all', 277 'accepted' => 'accepted', 278 'fields' => 'ids', 279 ); 280 $invites = $invites_class->get_invitations( $get_invites ); 281 $this->assertEqualSets( array( $i1, $r1 ), $invites ); 282 283 self::set_current_user( $old_current_user ); 284 } 285 286 public function test_bp_invitations_add_request_vanilla() { 287 $old_current_user = get_current_user_id(); 288 289 $u1 = self::factory()->user->create(); 290 self::set_current_user( $u1 ); 291 292 $invites_class = new BPTest_Invitation_Manager_Extension(); 293 294 // Create a couple of requests. 295 $request_args = array( 296 'user_id' => $u1, 297 'item_id' => 7, 298 ); 299 $r1 = $invites_class->add_request( $request_args ); 300 $request_args['item_id'] = 4; 301 $r2 = $invites_class->add_request( $request_args ); 302 303 $get_requests = array( 304 'user_id' => $u1, 305 'fields' => 'ids', 306 ); 307 $requests = $invites_class->get_requests( $get_requests ); 308 $this->assertEqualSets( array( $r1, $r2 ), $requests ); 309 310 self::set_current_user( $old_current_user ); 311 } 312 313 public function test_bp_invitations_add_request_avoid_duplicates() { 314 $old_current_user = get_current_user_id(); 315 316 $invites_class = new BPTest_Invitation_Manager_Extension(); 317 318 $u1 = self::factory()->user->create(); 319 self::set_current_user( $u1 ); 320 321 // Create a couple of requests. 322 $request_args = array( 323 'user_id' => $u1, 324 'item_id' => 7, 325 ); 326 $r1 = $invites_class->add_request( $request_args ); 327 // Attempt to create a duplicate. 328 $this->assertFalse( $invites_class->add_request( $request_args ) ); 329 330 self::set_current_user( $old_current_user ); 331 } 332 333 public function test_bp_invitations_add_request_request_plus_sent_invite_should_accept() { 334 $old_current_user = get_current_user_id(); 335 336 $u1 = self::factory()->user->create(); 337 $u2 = self::factory()->user->create(); 338 self::set_current_user( $u1 ); 339 340 $invites_class = new BPTest_Invitation_Manager_Extension(); 254 341 255 342 // Create a request. 256 343 $request_args = array( 257 'user_id' => $u3, 258 'item_id' => 1, 259 ); 260 $r1 = $invites_class->add_request( $request_args ); 261 262 $invites_class->send_invitation_by_id( $i1 ); 344 'user_id' => $u2, 345 'item_id' => 1, 346 ); 347 $r1 = $invites_class->add_request( $request_args ); 348 349 // Create an invitation. 350 $invite_args = array( 351 'user_id' => $u2, 352 'inviter_id' => $u1, 353 'item_id' => 1, 354 'send_invite' => 1, 355 ); 356 $i1 = $invites_class->add_invitation( $invite_args ); 263 357 264 358 // Check that both the request and invitation are marked 'accepted'. 265 359 $get_invites = array( 266 'user_id' => $u3, 267 'type' => 'all', 268 'accepted' => 'accepted', 269 'fields' => 'ids' 270 ); 271 $invites = $invites_class->get_invitations( $get_invites ); 272 $this->assertEqualSets( array( $i1, $r1 ), $invites ); 273 274 self::set_current_user( $old_current_user ); 275 } 276 277 public function test_bp_invitations_add_request_vanilla() { 278 $old_current_user = get_current_user_id(); 279 280 $u1 = self::factory()->user->create(); 281 self::set_current_user( $u1 ); 282 283 $invites_class = new BPTest_Invitation_Manager_Extension(); 284 285 // Create a couple of requests. 286 $request_args = array( 287 'user_id' => $u1, 288 'item_id' => 7, 289 ); 290 $r1 = $invites_class->add_request( $request_args ); 291 $request_args['item_id'] = 4; 292 $r2 = $invites_class->add_request( $request_args ); 293 294 $get_requests = array( 295 'user_id' => $u1, 296 'fields' => 'ids' 297 ); 298 $requests = $invites_class->get_requests( $get_requests ); 299 $this->assertEqualSets( array( $r1, $r2 ), $requests ); 300 301 self::set_current_user( $old_current_user ); 302 } 303 304 public function test_bp_invitations_add_request_avoid_duplicates() { 305 $old_current_user = get_current_user_id(); 306 307 $invites_class = new BPTest_Invitation_Manager_Extension(); 308 309 $u1 = self::factory()->user->create(); 310 self::set_current_user( $u1 ); 311 312 // Create a couple of requests. 313 $request_args = array( 314 'user_id' => $u1, 315 'item_id' => 7, 316 ); 317 $r1 = $invites_class->add_request( $request_args ); 318 // Attempt to create a duplicate. 319 $this->assertFalse( $invites_class->add_request( $request_args ) ); 320 321 self::set_current_user( $old_current_user ); 322 } 323 324 public function test_bp_invitations_add_request_request_plus_sent_invite_should_accept() { 325 $old_current_user = get_current_user_id(); 326 327 $u1 = self::factory()->user->create(); 328 $u2 = self::factory()->user->create(); 329 self::set_current_user( $u1 ); 330 331 $invites_class = new BPTest_Invitation_Manager_Extension(); 332 333 // Create a request. 334 $request_args = array( 335 'user_id' => $u2, 336 'item_id' => 1, 337 ); 338 $r1 = $invites_class->add_request( $request_args ); 339 340 // Create an invitation. 341 $invite_args = array( 342 'user_id' => $u2, 343 'inviter_id' => $u1, 344 'item_id' => 1, 345 'send_invite' => 1, 346 ); 347 $i1 = $invites_class->add_invitation( $invite_args ); 348 349 // Check that both the request and invitation are marked 'accepted'. 350 $get_invites = array( 351 'user_id' => $u2, 352 'type' => 'all', 353 'accepted' => 'accepted', 354 'fields' => 'ids' 355 ); 356 $invites = $invites_class->get_invitations( $get_invites ); 360 'user_id' => $u2, 361 'type' => 'all', 362 'accepted' => 'accepted', 363 'fields' => 'ids', 364 ); 365 $invites = $invites_class->get_invitations( $get_invites ); 357 366 $this->assertEqualSets( array( $r1, $i1 ), $invites ); 358 367 … … 371 380 // Create an invitation. 372 381 $invite_args = array( 373 'user_id' 374 'inviter_id' 375 'item_id' 376 ); 377 $i1 = $invites_class->add_invitation( $invite_args );382 'user_id' => $u2, 383 'inviter_id' => $u1, 384 'item_id' => 1, 385 ); 386 $i1 = $invites_class->add_invitation( $invite_args ); 378 387 379 388 $invite = new BP_Invitation( $i1 ); … … 404 413 'content' => 'Sometimes, the mystery is enough.', 405 414 ); 406 $i1 = $invites_class->add_invitation( $i1_args );415 $i1 = $invites_class->add_invitation( $i1_args ); 407 416 $invites_class->send_invitation_by_id( $i1 ); 408 417 … … 413 422 'item_id' => 1, 414 423 ); 415 $i2 = $invites_class->add_invitation( $i2_args );424 $i2 = $invites_class->add_invitation( $i2_args ); 416 425 $invites_class->send_invitation_by_id( $i2 ); 417 426 … … 420 429 'fields' => 'ids', 421 430 ); 422 $invites = $invites_class->get_invitations( $get_invites );431 $invites = $invites_class->get_invitations( $get_invites ); 423 432 $this->assertEqualSets( array( $i1 ), $invites ); 424 433 … … 427 436 'fields' => 'ids', 428 437 ); 429 $invites = $invites_class->get_invitations( $get_invites );438 $invites = $invites_class->get_invitations( $get_invites ); 430 439 $this->assertEqualSets( array( $i2 ), $invites ); 431 440 … … 443 452 $time = gmdate( 'Y-m-d H:i:s', time() - 100 ); 444 453 $args = array( 445 'user_id' 446 'item_id' 447 'date_modified' 448 ); 449 $r1 = $invites_class->add_request( $args );454 'user_id' => $u1, 455 'item_id' => 7, 456 'date_modified' => $time, 457 ); 458 $r1 = $invites_class->add_request( $args ); 450 459 451 460 $req = new BP_Invitation( $r1 ); … … 463 472 464 473 $invites_class = new BPTest_Invitation_Manager_Extension(); 465 $time = gmdate( 'Y-m-d H:i:s', time() - 100 );466 467 // Create an invitation. 468 $invite_args = array( 469 'user_id' 470 'inviter_id' 471 'item_id' 472 'send_invite' 473 'date_modified' 474 ); 475 $i1 = $invites_class->add_invitation( $invite_args );474 $time = gmdate( 'Y-m-d H:i:s', time() - 100 ); 475 476 // Create an invitation. 477 $invite_args = array( 478 'user_id' => $u2, 479 'inviter_id' => $u1, 480 'item_id' => 1, 481 'send_invite' => 1, 482 'date_modified' => $time, 483 ); 484 $i1 = $invites_class->add_invitation( $invite_args ); 476 485 477 486 $inv = new BP_Invitation( $i1 ); … … 497 506 'item_id' => 6, 498 507 ); 499 $i1 = $invites_class->add_invitation( $i1_args );508 $i1 = $invites_class->add_invitation( $i1_args ); 500 509 $invites_class->send_invitation_by_id( $i1 ); 501 510 … … 505 514 'item_id' => 4, 506 515 ); 507 $i2 = $invites_class->add_invitation( $i2_args );516 $i2 = $invites_class->add_invitation( $i2_args ); 508 517 $invites_class->send_invitation_by_id( $i2 ); 509 518 … … 513 522 'item_id' => 8, 514 523 ); 515 $i3 = $invites_class->add_invitation( $i3_args );524 $i3 = $invites_class->add_invitation( $i3_args ); 516 525 $invites_class->send_invitation_by_id( $i3 ); 517 526 … … 521 530 'fields' => 'ids', 522 531 ); 523 $invites = $invites_class->get_invitations( $get_invites );532 $invites = $invites_class->get_invitations( $get_invites ); 524 533 $this->assertEquals( array( $i2, $i1, $i3 ), $invites ); 525 534 526 535 $get_invites['sort_order'] = 'DESC'; 527 $invites = $invites_class->get_invitations( $get_invites );536 $invites = $invites_class->get_invitations( $get_invites ); 528 537 $this->assertEquals( array( $i3, $i1, $i2 ), $invites ); 529 538 -
trunk/tests/phpunit/testcases/groups/activity.php
r13980 r14026 15 15 $u = self::factory()->user->create(); 16 16 $g = self::factory()->group->create(); 17 $a = self::factory()->activity->create( array( 18 'component' => buddypress()->groups->id, 19 'type' => 'created_group', 20 'user_id' => $u, 21 'item_id' => $g, 22 ) ); 17 $a = self::factory()->activity->create( 18 array( 19 'component' => buddypress()->groups->id, 20 'type' => 'created_group', 21 'user_id' => $u, 22 'item_id' => $g, 23 ) 24 ); 23 25 24 26 $a_obj = new BP_Activity_Activity( $a ); 25 27 $g_obj = groups_get_group( $g ); 26 28 27 $expected = sprintf( __( '% s created the group %s', 'buddypress' ), bp_core_get_userlink( $u ),'<a href="' . esc_url( bp_get_group_url( $g_obj ) ) . '">' . $g_obj->name . '</a>' );29 $expected = sprintf( __( '%1$s created the group %2$s', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $g_obj ) ) . '">' . $g_obj->name . '</a>' ); 28 30 29 31 $this->assertSame( $expected, $a_obj->action ); … … 37 39 $u = self::factory()->user->create(); 38 40 $g = self::factory()->group->create(); 39 $a = self::factory()->activity->create( array( 40 'component' => buddypress()->groups->id, 41 'type' => 'joined_group', 42 'user_id' => $u, 43 'item_id' => $g, 44 ) ); 41 $a = self::factory()->activity->create( 42 array( 43 'component' => buddypress()->groups->id, 44 'type' => 'joined_group', 45 'user_id' => $u, 46 'item_id' => $g, 47 ) 48 ); 45 49 46 50 $a_obj = new BP_Activity_Activity( $a ); 47 51 $g_obj = groups_get_group( $g ); 48 52 49 $expected = sprintf( __( '% s joined the group %s', 'buddypress' ), bp_core_get_userlink( $u ),'<a href="' . esc_url( bp_get_group_url( $g_obj ) ) . '">' . $g_obj->name . '</a>' );53 $expected = sprintf( __( '%1$s joined the group %2$s', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $g_obj ) ) . '">' . $g_obj->name . '</a>' ); 50 54 51 55 $this->assertSame( $expected, $a_obj->action ); … … 58 62 public function test_bp_groups_format_activity_action_group_details_updated_with_no_change() { 59 63 $group = self::factory()->group->create_and_get(); 60 groups_edit_base_group_details( array( 64 groups_edit_base_group_details( 65 array( 61 66 'group_id' => $group->id, 62 67 'name' => $group->name, … … 64 69 'description' => $group->description, 65 70 'notify_members' => true, 66 ) ); 67 68 $a = bp_activity_get( array( 69 'component' => buddypress()->groups->id, 70 'action' => 'group_details_updated', 71 'item_id' => $group->id, 72 ) ); 71 ) 72 ); 73 74 $a = bp_activity_get( 75 array( 76 'component' => buddypress()->groups->id, 77 'action' => 'group_details_updated', 78 'item_id' => $group->id, 79 ) 80 ); 73 81 74 82 $this->assertTrue( empty( $a['activities'] ) ); … … 81 89 public function test_bp_groups_format_activity_action_group_details_updated_with_notify_members_false() { 82 90 $group = self::factory()->group->create_and_get(); 83 groups_edit_base_group_details( array( 84 'group_id' => $group->id, 85 'name' => 'Foo', 86 'slug' => $group->slug, 87 'description' => $group->description, 88 'notify_members' => false, 89 ) ); 90 91 $a = bp_activity_get( array( 92 'component' => buddypress()->groups->id, 93 'action' => 'group_details_updated', 94 'item_id' => $group->id, 95 ) ); 91 groups_edit_base_group_details( 92 array( 93 'group_id' => $group->id, 94 'name' => 'Foo', 95 'slug' => $group->slug, 96 'description' => $group->description, 97 'notify_members' => false, 98 ) 99 ); 100 101 $a = bp_activity_get( 102 array( 103 'component' => buddypress()->groups->id, 104 'action' => 'group_details_updated', 105 'item_id' => $group->id, 106 ) 107 ); 96 108 97 109 $this->assertTrue( empty( $a['activities'] ) ); … … 104 116 public function test_bp_groups_format_activity_action_group_details_updated_with_updated_name() { 105 117 $old_user = get_current_user_id(); 106 $u = self::factory()->user->create();118 $u = self::factory()->user->create(); 107 119 self::set_current_user( $u ); 108 120 109 121 $group = self::factory()->group->create_and_get(); 110 groups_edit_base_group_details( array( 111 'group_id' => $group->id, 112 'name' => 'Foo', 113 'slug' => $group->slug, 114 'description' => $group->description, 115 'notify_members' => true, 116 ) ); 117 118 $a = bp_activity_get( array( 119 'component' => buddypress()->groups->id, 120 'action' => 'group_details_updated', 121 'item_id' => $group->id, 122 ) ); 122 groups_edit_base_group_details( 123 array( 124 'group_id' => $group->id, 125 'name' => 'Foo', 126 'slug' => $group->slug, 127 'description' => $group->description, 128 'notify_members' => true, 129 ) 130 ); 131 132 $a = bp_activity_get( 133 array( 134 'component' => buddypress()->groups->id, 135 'action' => 'group_details_updated', 136 'item_id' => $group->id, 137 ) 138 ); 123 139 124 140 $this->assertNotEmpty( $a['activities'] ); 125 141 126 $expected = sprintf( esc_html__( '% s changed the name of the group %s from "%s" to "%s"', 'buddypress' ), bp_core_get_userlink( $u ),'<a href="' . esc_url( bp_get_group_url( $group ) ) . '">Foo</a>', $group->name, 'Foo' );142 $expected = sprintf( esc_html__( '%1$s changed the name of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $group ) ) . '">Foo</a>', $group->name, 'Foo' ); 127 143 $this->assertSame( $expected, $a['activities'][0]->action ); 128 144 … … 136 152 public function test_bp_groups_format_activity_action_group_details_updated_with_updated_description() { 137 153 $old_user = get_current_user_id(); 138 $u = self::factory()->user->create();154 $u = self::factory()->user->create(); 139 155 self::set_current_user( $u ); 140 156 141 157 $group = self::factory()->group->create_and_get(); 142 groups_edit_base_group_details( array( 143 'group_id' => $group->id, 144 'name' => $group->name, 145 'slug' => $group->slug, 146 'description' => 'Bar', 147 'notify_members' => true, 148 ) ); 149 150 $a = bp_activity_get( array( 151 'component' => buddypress()->groups->id, 152 'action' => 'group_details_updated', 153 'item_id' => $group->id, 154 ) ); 158 groups_edit_base_group_details( 159 array( 160 'group_id' => $group->id, 161 'name' => $group->name, 162 'slug' => $group->slug, 163 'description' => 'Bar', 164 'notify_members' => true, 165 ) 166 ); 167 168 $a = bp_activity_get( 169 array( 170 'component' => buddypress()->groups->id, 171 'action' => 'group_details_updated', 172 'item_id' => $group->id, 173 ) 174 ); 155 175 156 176 $this->assertNotEmpty( $a['activities'] ); 157 177 158 $expected = sprintf( esc_html__( '% s changed the description of the group %s from "%s" to "%s"', 'buddypress' ), bp_core_get_userlink( $u ),'<a href="' . esc_url( bp_get_group_url( $group ) ) . '">' . $group->name . '</a>', $group->description, 'Bar' );178 $expected = sprintf( esc_html__( '%1$s changed the description of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $group ) ) . '">' . $group->name . '</a>', $group->description, 'Bar' ); 159 179 $this->assertSame( $expected, $a['activities'][0]->action ); 160 180 … … 168 188 public function test_bp_groups_format_activity_action_group_details_updated_with_updated_slug() { 169 189 $old_user = get_current_user_id(); 170 $u = self::factory()->user->create();190 $u = self::factory()->user->create(); 171 191 self::set_current_user( $u ); 172 192 173 193 $group = self::factory()->group->create_and_get(); 174 groups_edit_base_group_details( array( 175 'group_id' => $group->id, 176 'name' => $group->name, 177 'slug' => 'flaxen', 178 'description' => $group->description, 179 'notify_members' => true, 180 ) ); 194 groups_edit_base_group_details( 195 array( 196 'group_id' => $group->id, 197 'name' => $group->name, 198 'slug' => 'flaxen', 199 'description' => $group->description, 200 'notify_members' => true, 201 ) 202 ); 181 203 $new_group_details = groups_get_group( $group->id ); 182 204 183 $a = bp_activity_get( array( 184 'component' => buddypress()->groups->id, 185 'action' => 'group_details_updated', 186 'item_id' => $group->id, 187 ) ); 205 $a = bp_activity_get( 206 array( 207 'component' => buddypress()->groups->id, 208 'action' => 'group_details_updated', 209 'item_id' => $group->id, 210 ) 211 ); 188 212 189 213 $this->assertNotEmpty( $a['activities'] ); 190 214 191 $expected = sprintf( __( '% s changed the permalink of the group %s.', 'buddypress' ), bp_core_get_userlink( $u ),'<a href="' . esc_url( bp_get_group_url( $new_group_details ) ) . '">' . $group->name . '</a>' );215 $expected = sprintf( __( '%1$s changed the permalink of the group %2$s.', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $new_group_details ) ) . '">' . $group->name . '</a>' ); 192 216 $this->assertSame( $expected, $a['activities'][0]->action ); 193 217 … … 201 225 public function test_bp_groups_format_activity_action_group_details_updated_with_updated_name_and_description() { 202 226 $old_user = get_current_user_id(); 203 $u = self::factory()->user->create();227 $u = self::factory()->user->create(); 204 228 self::set_current_user( $u ); 205 229 206 230 $group = self::factory()->group->create_and_get(); 207 groups_edit_base_group_details( array( 208 'group_id' => $group->id, 209 'name' => 'Foo', 210 'slug' => $group->slug, 211 'description' => 'Bar', 212 'notify_members' => true, 213 ) ); 214 215 $a = bp_activity_get( array( 216 'component' => buddypress()->groups->id, 217 'action' => 'group_details_updated', 218 'item_id' => $group->id, 219 ) ); 231 groups_edit_base_group_details( 232 array( 233 'group_id' => $group->id, 234 'name' => 'Foo', 235 'slug' => $group->slug, 236 'description' => 'Bar', 237 'notify_members' => true, 238 ) 239 ); 240 241 $a = bp_activity_get( 242 array( 243 'component' => buddypress()->groups->id, 244 'action' => 'group_details_updated', 245 'item_id' => $group->id, 246 ) 247 ); 220 248 221 249 $this->assertNotEmpty( $a['activities'] ); 222 250 223 $expected = sprintf( __( '% s changed the name and description of the group %s', 'buddypress' ), bp_core_get_userlink( $u ),'<a href="' . esc_url( bp_get_group_url( $group ) ) . '">Foo</a>' );251 $expected = sprintf( __( '%1$s changed the name and description of the group %2$s', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $group ) ) . '">Foo</a>' ); 224 252 $this->assertSame( $expected, $a['activities'][0]->action ); 225 253 … … 234 262 $u = self::factory()->user->create(); 235 263 $g = self::factory()->group->create(); 236 $a = self::factory()->activity->create( array( 237 'component' => buddypress()->groups->id, 238 'type' => 'activity_update', 239 'user_id' => $u, 240 'item_id' => $g, 241 ) ); 264 $a = self::factory()->activity->create( 265 array( 266 'component' => buddypress()->groups->id, 267 'type' => 'activity_update', 268 'user_id' => $u, 269 'item_id' => $g, 270 ) 271 ); 242 272 243 273 $a_obj = new BP_Activity_Activity( $a ); 244 274 $g_obj = groups_get_group( $g ); 245 275 246 $expected = sprintf( esc_html__( '%1$s posted an update in the group %2$s', 'buddypress' ), bp_core_get_userlink( $u ), 276 $expected = sprintf( esc_html__( '%1$s posted an update in the group %2$s', 'buddypress' ), bp_core_get_userlink( $u ), '<a href="' . esc_url( bp_get_group_url( $g_obj ) ) . '">' . esc_html( $g_obj->name ) . '</a>' ); 247 277 248 278 $this->assertSame( $expected, $a_obj->action ); … … 296 326 ); 297 327 298 $a = groups_post_update( $activity_args );328 $a = groups_post_update( $activity_args ); 299 329 $a_obj = new BP_Activity_Activity( $a ); 300 330 … … 310 340 public function test_groups_activity_can_comment() { 311 341 $old_user = get_current_user_id(); 312 $u1 = self::factory()->user->create();313 $u2 = self::factory()->user->create();342 $u1 = self::factory()->user->create(); 343 $u2 = self::factory()->user->create(); 314 344 315 345 $g = self::factory()->group->create(); … … 318 348 groups_join_group( $g, $u1 ); 319 349 320 $a = self::factory()->activity->create( array( 321 'component' => buddypress()->groups->id, 322 'type' => 'created_group', 323 'user_id' => $u1, 324 'item_id' => $g, 325 ) ); 350 $a = self::factory()->activity->create( 351 array( 352 'component' => buddypress()->groups->id, 353 'type' => 'created_group', 354 'user_id' => $u1, 355 'item_id' => $g, 356 ) 357 ); 326 358 327 359 self::set_current_user( $u1 ); 328 360 if ( bp_has_activities( array( 'in' => $a ) ) ) { 329 while ( bp_activities() ) : bp_the_activity(); 361 while ( bp_activities() ) : 362 bp_the_activity(); 330 363 // User 1 should be able to comment. 331 364 $this->assertTrue( bp_activity_can_comment() ); … … 335 368 self::set_current_user( $u2 ); 336 369 if ( bp_has_activities( array( 'in' => $a ) ) ) { 337 while ( bp_activities() ) : bp_the_activity(); 370 while ( bp_activities() ) : 371 bp_the_activity(); 338 372 // User 2 should not be able to comment. 339 373 $this->assertFalse( bp_activity_can_comment() ); … … 345 379 346 380 public function groups_post_update_args( $args = array() ) { 347 $this->groups_post_update_args = array_intersect_key( $args, array( 348 'content' => true, 349 'user_id' => true, 350 'item_id' => true, 351 'error_type' => true, 352 ) ); 381 $this->groups_post_update_args = array_intersect_key( 382 $args, 383 array( 384 'content' => true, 385 'user_id' => true, 386 'item_id' => true, 387 'error_type' => true, 388 ) 389 ); 353 390 354 391 return $args; … … 359 396 */ 360 397 public function test_user_can_delete_group_activity() { 361 $u1 362 $u2 398 $u1 = self::factory()->user->create(); 399 $u2 = self::factory()->user->create(); 363 400 $original_user = bp_loggedin_user_id(); 364 401 … … 416 453 417 454 // Misc user can't delete activity. 418 $misc_user = self::factory()->user->create( array( 'role' => 'subscriber' ));455 $misc_user = self::factory()->user->create(); 419 456 self::set_current_user( $misc_user ); 420 457 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 421 458 422 459 // Misc group member can't delete activity. 423 $misc_user_2 = self::factory()->user->create( array( 'role' => 'subscriber' ));460 $misc_user_2 = self::factory()->user->create(); 424 461 self::add_user_to_group( $misc_user_2, $g ); 425 462 self::set_current_user( $misc_user_2 ); … … 427 464 428 465 // Group mod can delete activity. 429 $misc_user_3 = self::factory()->user->create( array( 'role' => 'subscriber' ));430 self::add_user_to_group( $misc_user_3, $g, [ 'is_mod' => true ]);466 $misc_user_3 = self::factory()->user->create(); 467 self::add_user_to_group( $misc_user_3, $g, array( 'is_mod' => true ) ); 431 468 self::set_current_user( $misc_user_3 ); 432 469 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); 433 470 434 471 // Group admin can delete activity. 435 $misc_user_4 = self::factory()->user->create( array( 'role' => 'subscriber' ));436 self::add_user_to_group( $misc_user_4, $g, [ 'is_admin' => true ]);472 $misc_user_4 = self::factory()->user->create(); 473 self::add_user_to_group( $misc_user_4, $g, array( 'is_admin' => true ) ); 437 474 self::set_current_user( $misc_user_4 ); 438 475 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); … … 455 492 $a = self::factory()->activity->create( 456 493 array( 457 'user_id' 458 'content' 494 'user_id' => $u1, 495 'content' => 'Random Activity content', 459 496 ) 460 497 ); … … 484 521 485 522 // Add u2 as Admin of g2. 486 self::add_user_to_group( $u2, $g, [ 'is_admin' => true ]);523 self::add_user_to_group( $u2, $g, array( 'is_admin' => true ) ); 487 524 488 525 self::set_current_user( $u2 ); -
trunk/tests/phpunit/testcases/members/class-bp-signup.php
r13989 r14026 4 4 * @group members 5 5 * @group signups 6 * @group signup 6 7 * @group BP_Signup 7 8 */ -
trunk/tests/phpunit/testcases/members/functions.php
r13985 r14026 34 34 // 1. Admin can delete user account 35 35 $this->set_current_user( $admin_user ); 36 $user1 = self::factory()->user->create( array( 'role' => 'subscriber' ));36 $user1 = self::factory()->user->create(); 37 37 bp_core_delete_account( $user1 ); 38 38 $maybe_user = new WP_User( $user1 ); … … 50 50 51 51 // User cannot delete other's account 52 $user3 = self::factory()->user->create( array( 'role' => 'subscriber' ));53 $user4 = self::factory()->user->create( array( 'role' => 'subscriber' ));52 $user3 = self::factory()->user->create(); 53 $user4 = self::factory()->user->create(); 54 54 $this->set_current_user( $user3 ); 55 55 bp_core_delete_account( $user4 ); … … 129 129 public function test_bp_members_get_user_url_after_directory_page_update() { 130 130 // Generate user 131 $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ));131 $user_id = self::factory()->user->create(); 132 132 $this->set_permalink_structure( '/%postname%/' ); 133 133 -
trunk/tests/phpunit/testcases/testsuite/factory.php
r11737 r14026 3 3 /** 4 4 * @group testsuite 5 * @group factory 5 6 */ 6 class BP Tests_Testsuite_Factory extends BP_UnitTestCase {7 class BP_Tests_Testsuite_Factory extends BP_UnitTestCase { 7 8 /** 8 9 * @ticket BP7234 … … 44 45 $u2 = self::factory()->user->create(); 45 46 46 $f = self::factory()->friendship->create_and_get( array( 47 'initiator_user_id' => $u1, 48 'friend_user_id' => $u2, 49 ) ); 47 $f = self::factory()->friendship->create_and_get( 48 array( 49 'initiator_user_id' => $u1, 50 'friend_user_id' => $u2, 51 ) 52 ); 50 53 51 54 $this->assertSame( $u1, $f->initiator_user_id ); -
trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field.php
r13980 r14026 11 11 public function test_can_delete_save() { 12 12 $group = self::factory()->xprofile_group->create(); 13 $field = self::factory()->xprofile_field->create( array( 14 'field_group_id' => $group, 15 ) ); 16 17 $f = new BP_XProfile_Field( $field ); 13 $field = self::factory()->xprofile_field->create( 14 array( 15 'field_group_id' => $group, 16 ) 17 ); 18 19 $f = new BP_XProfile_Field( $field ); 18 20 $f->can_delete = 0; 19 21 $f->save(); … … 32 34 $_POST['checkbox_option'] = array( 33 35 1 => 'BuddyPress', 34 2 => 'WordPress' 36 2 => 'WordPress', 35 37 ); 36 38 37 39 // checkbox field 38 $f1 = self::factory()->xprofile_field->create( array( 39 'field_group_id' => $group, 40 'type' => 'checkbox', 41 'name' => 'Interests' 42 ) ); 40 $f1 = self::factory()->xprofile_field->create( 41 array( 42 'field_group_id' => $group, 43 'type' => 'checkbox', 44 'name' => 'Interests', 45 ) 46 ); 43 47 44 48 // textbox field with the same name as our checkbox value 45 $f2 = self::factory()->xprofile_field->create( array( 46 'field_group_id' => $group, 47 'type' => 'textbox', 48 'name' => 'BuddyPress' 49 ) ); 49 $f2 = self::factory()->xprofile_field->create( 50 array( 51 'field_group_id' => $group, 52 'type' => 'textbox', 53 'name' => 'BuddyPress', 54 ) 55 ); 50 56 51 57 $this->assertEquals( $f2, xprofile_get_field_id_from_name( 'BuddyPress' ) ); … … 105 111 $_POST['required'], 106 112 $_POST['fieldtype'], 107 $_POST['radio_option' 113 $_POST['radio_option'] 108 114 ); 109 115 } … … 113 119 */ 114 120 public function test_newly_created_field_should_have_field_id_property_set() { 115 $field = new BP_XProfile_Field();121 $field = new BP_XProfile_Field(); 116 122 $field->group_id = 1; 117 $field->name = 'Foo';123 $field->name = 'Foo'; 118 124 119 125 $new_field_id = $field->save(); … … 129 135 130 136 $group = self::factory()->xprofile_group->create(); 131 $field = self::factory()->xprofile_field->create( array( 132 'field_group_id' => $group, 133 ) ); 137 $field = self::factory()->xprofile_field->create( 138 array( 139 'field_group_id' => $group, 140 ) 141 ); 134 142 135 143 bp_xprofile_update_meta( $field, 'field', 'default_visibility', 'loggedin' ); … … 137 145 // Initial setup takes just one query. 138 146 $num_queries = $wpdb->num_queries; 139 $field_obj = new BP_XProfile_Field( $field );140 $num_queries++;147 $field_obj = new BP_XProfile_Field( $field ); 148 ++$num_queries; 141 149 142 150 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 144 152 // Fetching the default_visibility should cause another query. 145 153 $this->assertSame( 'loggedin', $field_obj->default_visibility ); 146 $num_queries++;154 ++$num_queries; 147 155 148 156 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 156 164 157 165 $group = self::factory()->xprofile_group->create(); 158 $field = self::factory()->xprofile_field->create( array( 159 'field_group_id' => $group, 160 ) ); 166 $field = self::factory()->xprofile_field->create( 167 array( 168 'field_group_id' => $group, 169 ) 170 ); 161 171 162 172 bp_xprofile_update_meta( $field, 'field', 'allow_custom_visibility', 'disabled' ); … … 164 174 // Initial setup takes just one query. 165 175 $num_queries = $wpdb->num_queries; 166 $field_obj = new BP_XProfile_Field( $field );167 $num_queries++;176 $field_obj = new BP_XProfile_Field( $field ); 177 ++$num_queries; 168 178 169 179 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 171 181 // Fetching the allow_custom_visibility should cause another query. 172 182 $this->assertSame( 'disabled', $field_obj->allow_custom_visibility ); 173 $num_queries++;183 ++$num_queries; 174 184 175 185 $this->assertSame( $num_queries, $wpdb->num_queries ); … … 190 200 public function test_update_position_should_invalidate_cache() { 191 201 $group = self::factory()->xprofile_group->create(); 192 $field = self::factory()->xprofile_field->create( array( 193 'field_group_id' => $group, 194 ) ); 202 $field = self::factory()->xprofile_field->create( 203 array( 204 'field_group_id' => $group, 205 ) 206 ); 195 207 196 208 // Prime cache. 197 $fetched_field = xprofile_get_field( $field );209 $fetched_field = xprofile_get_field( $field ); 198 210 $new_field_order = 12345; 199 211 … … 210 222 */ 211 223 public function test_empty_datebox_fields_should_not_return_unix_epoch() { 212 $user = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 213 $group = self::factory()->xprofile_group->create(); 214 $field = self::factory()->xprofile_field->create( array( 215 'field_group_id' => $group, 216 'type' => 'datebox', 217 ) ); 224 $user = self::factory()->user->create(); 225 $group = self::factory()->xprofile_group->create(); 226 $field = self::factory()->xprofile_field->create( 227 array( 228 'field_group_id' => $group, 229 'type' => 'datebox', 230 ) 231 ); 218 232 219 233 $old_user = get_current_user_id(); 220 234 self::set_current_user( $user ); 221 235 222 $value = bp_get_profile_field_data( array( 'user_id' => $user, 'field' => $field ) ); 236 $value = bp_get_profile_field_data( 237 array( 238 'user_id' => $user, 239 'field' => $field, 240 ) 241 ); 223 242 $this->assertEmpty( $value ); 224 243 … … 231 250 public function test_delete_field_should_delete_default_field_metadata() { 232 251 $group = self::factory()->xprofile_group->create(); 233 $field = self::factory()->xprofile_field->create( array( 234 'field_group_id' => $group 235 ) ); 252 $field = self::factory()->xprofile_field->create( 253 array( 254 'field_group_id' => $group, 255 ) 256 ); 236 257 237 258 $field_obj = new BP_XProfile_Field( $field ); … … 247 268 public function test_delete_field_should_delete_custom_field_metadata() { 248 269 $group = self::factory()->xprofile_group->create(); 249 $field = self::factory()->xprofile_field->create( array( 250 'field_group_id' => $group 251 ) ); 270 $field = self::factory()->xprofile_field->create( 271 array( 272 'field_group_id' => $group, 273 ) 274 ); 252 275 253 276 bp_xprofile_update_meta( $field, 'field', 'custom', 'metadata' );
Note: See TracChangeset
for help on using the changeset viewer.