Changeset 8175
- Timestamp:
- 03/27/2014 06:20:37 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r8135 r8175 407 407 $user_id = bp_loggedin_user_id(); 408 408 409 // Update the user's personal favorites 410 $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); 409 $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); 410 if ( empty( $my_favs ) || ! is_array( $my_favs ) ) { 411 $my_favs = array(); 412 } 413 414 // Bail if the user has already favorited this activity item 415 if ( in_array( $activity_id, $my_favs ) ) { 416 return false; 417 } 418 419 // Add to user's favorites 411 420 $my_favs[] = $activity_id; 412 421 -
trunk/tests/testcases/activity/functions.php
r8133 r8175 696 696 } 697 697 698 /** 699 * @group favorites 700 * @group bp_activity_add_user_favorite 701 */ 702 public function test_add_user_favorite_already_favorited() { 703 $u = $this->create_user(); 704 $a = $this->factory->activity->create(); 705 706 bp_activity_add_user_favorite( $a, $u ); 707 708 $this->assertFalse( bp_activity_add_user_favorite( $a, $u ) ); 709 $this->assertSame( array( $a ), bp_activity_get_user_favorites( $u ) ); 710 $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) ); 711 } 712 698 713 public function check_activity_caches() { 699 714 foreach ( $this->acaches as $k => $v ) {
Note: See TracChangeset
for help on using the changeset viewer.