Example #1
0
 /**
  * @group bp_migrate_new_member_activity_component
  */
 public function test_bp_migrate_new_member_activity_component()
 {
     global $wpdb;
     $bp = buddypress();
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $u3 = $this->factory->user->create();
     $au1 = $this->factory->activity->create(array('component' => 'xprofile', 'type' => 'new_member', 'user_id' => $u1));
     $au2 = $this->factory->activity->create(array('component' => 'xprofile', 'type' => 'new_member', 'user_id' => $u2));
     $au3 = $this->factory->activity->create(array('component' => 'xprofile', 'type' => 'new_member', 'user_id' => $u3));
     bp_migrate_new_member_activity_component();
     $expected = array($u1 => $au1, $u2 => $au2, $u3 => $au3);
     $in = "'" . implode("', '", array_keys($expected)) . "'";
     $found = $wpdb->get_results($wpdb->prepare("SELECT user_id, id FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = %s AND user_id IN ({$in}) ORDER BY user_id ASC", $bp->members->id, 'new_member'), OBJECT_K);
     $found = array_map('intval', wp_list_pluck($found, 'id'));
     $this->assertSame($expected, $found);
 }
/**
 * 2.2.0 update routine.
 *
 * - Add messages meta table.
 * - Update the component field of the 'new members' activity type.
 * - Clean up hidden friendship activities.
 *
 * @since 2.2.0
 */
function bp_update_to_2_2()
{
    // Also handled by `bp_core_install()`
    if (bp_is_active('messages')) {
        bp_core_install_private_messaging();
    }
    if (bp_is_active('activity')) {
        bp_migrate_new_member_activity_component();
        if (bp_is_active('friends')) {
            bp_cleanup_friendship_activities();
        }
    }
}