| 345 | * @group scope |
| 346 | * @group filter_query |
| 347 | * @group BP_Activity_Query |
| 348 | */ |
| 349 | function test_bp_has_activities_scope_friends_no_items() { |
| 350 | $u1 = $this->factory->user->create(); |
| 351 | |
| 352 | $now = time(); |
| 353 | |
| 354 | // Create a random activity |
| 355 | $a1 = $this->factory->activity->create( array( |
| 356 | 'user_id' => $u1, |
| 357 | 'type' => 'activity_update', |
| 358 | 'recorded_time' => date( 'Y-m-d H:i:s', $now ), |
| 359 | ) ); |
| 360 | |
| 361 | global $activities_template; |
| 362 | $reset_activities_template = $activities_template; |
| 363 | |
| 364 | // grab activities from friends scope |
| 365 | bp_has_activities( array( |
| 366 | 'user_id' => $u1, |
| 367 | 'scope' => 'friends', |
| 368 | ) ); |
| 369 | |
| 370 | // assert! |
| 371 | $this->assertEmpty( $activities_template->activities, 'When a user does not have any friendship, no activities should be fetched when on friends scope' ); |
| 372 | |
| 373 | // clean up! |
| 374 | $activities_template = $reset_activities_template; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * @group scope |
| 379 | * @group filter_query |
| 380 | * @group BP_Activity_Query |
| 381 | */ |
| 382 | function test_bp_has_activities_scope_favorites_no_items() { |
| 383 | $u1 = $this->factory->user->create(); |
| 384 | |
| 385 | $now = time(); |
| 386 | |
| 387 | // Create a random activity |
| 388 | $a1 = $this->factory->activity->create( array( |
| 389 | 'user_id' => $u1, |
| 390 | 'type' => 'activity_update', |
| 391 | 'recorded_time' => date( 'Y-m-d H:i:s', $now ), |
| 392 | ) ); |
| 393 | |
| 394 | global $activities_template; |
| 395 | $reset_activities_template = $activities_template; |
| 396 | |
| 397 | // grab activities from favorites scope |
| 398 | bp_has_activities( array( |
| 399 | 'user_id' => $u1, |
| 400 | 'scope' => 'favorites', |
| 401 | ) ); |
| 402 | |
| 403 | // assert! |
| 404 | $this->assertEmpty( $activities_template->activities, 'When a user has not favorited any activity, no activities should be fetched when on favorites scope' ); |
| 405 | |
| 406 | // clean up! |
| 407 | $activities_template = $reset_activities_template; |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * @group scope |
| 412 | * @group filter_query |
| 413 | * @group BP_Activity_Query |
| 414 | */ |
| 415 | function test_bp_has_activities_scope_groups_no_items() { |
| 416 | $u1 = $this->factory->user->create(); |
| 417 | |
| 418 | $now = time(); |
| 419 | |
| 420 | // Create a random activity |
| 421 | $a1 = $this->factory->activity->create( array( |
| 422 | 'user_id' => $u1, |
| 423 | 'type' => 'activity_update', |
| 424 | 'recorded_time' => date( 'Y-m-d H:i:s', $now ), |
| 425 | ) ); |
| 426 | |
| 427 | global $activities_template; |
| 428 | $reset_activities_template = $activities_template; |
| 429 | |
| 430 | // grab activities from groups scope |
| 431 | bp_has_activities( array( |
| 432 | 'user_id' => $u1, |
| 433 | 'scope' => 'groups', |
| 434 | ) ); |
| 435 | |
| 436 | // assert! |
| 437 | $this->assertEmpty( $activities_template->activities, 'When a user is not a member of any group, no activities should be fetched when on groups scope' ); |
| 438 | |
| 439 | // clean up! |
| 440 | $activities_template = $reset_activities_template; |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * @group scope |
| 445 | * @group filter_query |
| 446 | * @group BP_Activity_Query |
| 447 | */ |
| 448 | function test_bp_has_activities_scope_mentions_no_items() { |
| 449 | $u1 = $this->factory->user->create(); |
| 450 | |
| 451 | $now = time(); |
| 452 | |
| 453 | // Create a random activity |
| 454 | $a1 = $this->factory->activity->create( array( |
| 455 | 'user_id' => $u1, |
| 456 | 'type' => 'activity_update', |
| 457 | 'recorded_time' => date( 'Y-m-d H:i:s', $now ), |
| 458 | ) ); |
| 459 | |
| 460 | global $activities_template; |
| 461 | $reset_activities_template = $activities_template; |
| 462 | |
| 463 | // grab activities from mentions scope |
| 464 | bp_has_activities( array( |
| 465 | 'user_id' => $u1, |
| 466 | 'scope' => 'mentions', |
| 467 | ) ); |
| 468 | |
| 469 | // assert! |
| 470 | $this->assertEmpty( $activities_template->activities, 'When a user has no mention, no activities should be fetched when on the mentions scope' ); |
| 471 | |
| 472 | // clean up! |
| 473 | $activities_template = $reset_activities_template; |
| 474 | } |
| 475 | |
| 476 | /** |