Changeset 14026 for trunk/tests/phpunit/testcases/activity/template.php
- Timestamp:
- 09/27/2024 09:11:27 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 );
Note: See TracChangeset
for help on using the changeset viewer.