<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][9273] trunk: Move the 'new_member' activity type into the Members component</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/9273">9273</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/9273","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2014-12-24 04:35:52 +0000 (Wed, 24 Dec 2014)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Move the 'new_member' activity type into the Members component

Since BuddyPress 1.1, the 'new_member' type was attached to the xProfile component. In version 2.2, we are moving it into the Members one. Once the user will have upgraded to this version, every existing 'new_member' activity items will have their component updated to the 'members' one and each time a new member will register, the 'new_member' activity will be attached to the members component.

Props boonebgorges, DJPaul

Fixes <a href="http://buddypress.trac.wordpress.org/ticket/5807">#5807</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivityclassesphp">trunk/src/bp-activity/bp-activity-classes.php</a></li>
<li><a href="#trunksrcbpcorebpcoreupdatephp">trunk/src/bp-core/bp-core-update.php</a></li>
<li><a href="#trunksrcbpcoredeprecated22php">trunk/src/bp-core/deprecated/2.2.php</a></li>
<li><a href="#trunksrcbpmembersbpmembersfunctionsphp">trunk/src/bp-members/bp-members-functions.php</a></li>
<li><a href="#trunksrcbpmembersbpmembersloaderphp">trunk/src/bp-members/bp-members-loader.php</a></li>
<li><a href="#trunksrcbpxprofilebpxprofileactivityphp">trunk/src/bp-xprofile/bp-xprofile-activity.php</a></li>
<li><a href="#trunktestsphpunittestcasesxprofileactivityphp">trunk/tests/phpunit/testcases/xprofile/activity.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcbpmembersbpmembersactivityphp">trunk/src/bp-members/bp-members-activity.php</a></li>
<li><a href="#trunktestsphpunittestcasesmembersactivityphp">trunk/tests/phpunit/testcases/members/activity.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-classes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-classes.php     2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/src/bp-activity/bp-activity-classes.php       2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -435,11 +435,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $excluded_types[] = 'last_activity';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Exclude 'new_member' items if xprofile component is not active
-               if ( ! bp_is_active( 'xprofile' ) ) {
-                       $excluded_types[] = 'new_member';
-               }
-
</del><span class="cx" style="display: block; padding: 0 10px">                 // Build the excluded type sql part
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! empty( $excluded_types ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
</span></span></pre></div>
<a id="trunksrcbpcorebpcoreupdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-update.php      2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/src/bp-core/bp-core-update.php        2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -398,6 +398,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * 2.2.0 update routine.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * - Add messages meta table
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * - Update the component field of the 'new members' activity type
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since BuddyPress (2.2.0)
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -405,9 +406,49 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( bp_is_active( 'messages' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                bp_core_install_private_messaging();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       if ( bp_is_active( 'activity' ) ) {
+               bp_migrate_new_member_activity_component();
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Updates the component field for new_members type.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @global $wpdb
+ * @uses   buddypress()
+ *
+ */
+function bp_migrate_new_member_activity_component() {
+       global $wpdb;
+       $bp = buddypress();
+
+       // Update the component for the new_member type
+       $wpdb->update(
+               // Activity table
+               $bp->members->table_name_last_activity,
+               array(
+                       'component' => $bp->members->id,
+               ),
+               array(
+                       'component' => 'xprofile',
+                       'type'      => 'new_member',
+               ),
+               // Data sanitization format
+               array(
+                       '%s',
+               ),
+               // WHERE sanitization format
+               array(
+                       '%s',
+                       '%s'
+               )
+       );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Redirect user to BP's What's New page on first page load after activation.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since BuddyPress (1.7.0)
</span></span></pre></div>
<a id="trunksrcbpcoredeprecated22php"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/deprecated/2.2.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/deprecated/2.2.php      2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/src/bp-core/deprecated/2.2.php        2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,3 +77,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">        _deprecated_function( __FUNCTION__, '2.2', 'bp_blogs_clear_blog_object_cache()' );
</span><span class="cx" style="display: block; padding: 0 10px">        bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Format 'new_member' activity actions.
+ *
+ * @since BuddyPress (2.0.0)
+ * @deprecated BuddyPress (2.2.0)
+ *
+ * @param string $action Static activity action.
+ * @param object $activity Activity object.
+ * @return string
+ */
+function bp_xprofile_format_activity_action_new_member( $action, $activity ) {
+       _deprecated_function( __FUNCTION__, '2.2', 'bp_members_format_activity_action_new_member()' );
+
+       $action = apply_filters( 'bp_xprofile_format_activity_action_new_member', $action, $activity );
+       return bp_members_format_activity_action_new_member( $action, $activity );
+}
</ins></span></pre></div>
<a id="trunksrcbpmembersbpmembersactivityphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-members/bp-members-activity.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/bp-members-activity.php                              (rev 0)
+++ trunk/src/bp-members/bp-members-activity.php        2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,83 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * BuddyPress Member Activity
+ *
+ * @package BuddyPress
+ * @subpackage MembersActivity
+ */
+
+// Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+/**
+ * Register the 'new member' activity type
+ *
+ * @since  BuddyPress (2.2.0)
+ *
+ * @uses bp_activity_set_action()
+ * @uses buddypress()
+ */
+function bp_members_register_activity_actions() {
+
+       bp_activity_set_action(
+               buddypress()->members->id,
+               'new_member',
+               __( 'New member registered', 'buddypress' ),
+               'bp_members_format_activity_action_new_member',
+               __( 'New Members', 'buddypress' ),
+               array( 'activity' )
+       );
+
+       do_action( 'bp_members_register_activity_actions' );
+}
+add_action( 'bp_register_activity_actions', 'bp_members_register_activity_actions' );
+
+/**
+ * Format 'new_member' activity actions.
+ *
+ * @since BuddyPress (2.2.0)
+ *
+ * @param string $action Static activity action.
+ * @param object $activity Activity object.
+ * @return string
+ */
+function bp_members_format_activity_action_new_member( $action, $activity ) {
+       $userlink = bp_core_get_userlink( $activity->user_id );
+       $action   = sprintf( __( '%s became a registered member', 'buddypress' ), $userlink );
+
+       // Legacy filter - pass $user_id instead of $activity
+       if ( has_filter( 'bp_core_activity_registered_member_action' ) ) {
+               $action = apply_filters( 'bp_core_activity_registered_member_action', $action, $activity->user_id );
+       }
+
+       return apply_filters( 'bp_members_format_activity_action_new_member', $action, $activity );
+}
+
+/**
+ * Create a "became a registered user" activity item when a user activates his account.
+ *
+ * @param array $user Array of userdata passed to bp_core_activated_user hook.
+ */
+function bp_core_new_user_activity( $user ) {
+       if ( empty( $user ) ) {
+               return false;
+       }
+
+       if ( is_array( $user ) ) {
+               $user_id = $user['user_id'];
+       } else {
+               $user_id = $user;
+       }
+
+       if ( empty( $user_id ) ) {
+               return false;
+       }
+
+       bp_activity_add( array(
+               'user_id'   => $user_id,
+               'component' => buddypress()->members->id,
+               'type'      => 'new_member'
+       ) );
+}
+add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
</ins></span></pre></div>
<a id="trunksrcbpmembersbpmembersfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/bp-members-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/bp-members-functions.php     2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/src/bp-members/bp-members-functions.php       2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2125,34 +2125,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Create a "became a registered user" activity item when a user activates his account.
- *
- * @param array $user Array of userdata passed to bp_core_activated_user hook.
- */
-function bp_core_new_user_activity( $user ) {
-       if ( empty( $user ) || ! bp_is_active( 'activity' ) || ! bp_is_active( 'xprofile' ) ) {
-               return false;
-       }
-
-       if ( is_array( $user ) ) {
-               $user_id = $user['user_id'];
-       } else {
-               $user_id = $user;
-       }
-
-       if ( empty( $user_id ) ) {
-               return false;
-       }
-
-       bp_activity_add( array(
-               'user_id'   => $user_id,
-               'component' => 'xprofile',
-               'type'      => 'new_member'
-       ) );
-}
-add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px">  * Map a user's WP display name to the XProfile fullname field, if necessary.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * This only happens when a user is registered in wp-admin by an administrator;
</span></span></pre></div>
<a id="trunksrcbpmembersbpmembersloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/bp-members-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/bp-members-loader.php        2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/src/bp-members/bp-members-loader.php  2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,6 +59,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'cache',
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( bp_is_active( 'activity' ) ) {
+                       $includes[] = 'activity';
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // Include these only if in admin
</span><span class="cx" style="display: block; padding: 0 10px">                if ( is_admin() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $includes[] = 'admin';
</span></span></pre></div>
<a id="trunksrcbpxprofilebpxprofileactivityphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-xprofile/bp-xprofile-activity.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-xprofile/bp-xprofile-activity.php    2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/src/bp-xprofile/bp-xprofile-activity.php      2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,20 +33,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                __( 'Updated Profile Photos', 'buddypress' )
</span><span class="cx" style="display: block; padding: 0 10px">        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // Get the profile component ID
-       $profile_id = buddypress()->profile->id;
-
</del><span class="cx" style="display: block; padding: 0 10px">         bp_activity_set_action(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $profile_id,
-               'new_member',
-               __( 'New member registered', 'buddypress' ),
-               'bp_xprofile_format_activity_action_new_member',
-               __( 'New Members', 'buddypress' ),
-               array( 'activity' )
-       );
-
-       bp_activity_set_action(
-               $profile_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         buddypress()->profile->id,
</ins><span class="cx" style="display: block; padding: 0 10px">                 'updated_profile',
</span><span class="cx" style="display: block; padding: 0 10px">                __( 'Updated Profile', 'buddypress' ),
</span><span class="cx" style="display: block; padding: 0 10px">                'bp_xprofile_format_activity_action_updated_profile',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,27 +68,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Format 'new_member' activity actions.
- *
- * @since BuddyPress (2.0.0)
- *
- * @param string $action Static activity action.
- * @param object $activity Activity object.
- * @return string
- */
-function bp_xprofile_format_activity_action_new_member( $action, $activity ) {
-       $userlink = bp_core_get_userlink( $activity->user_id );
-       $action   = sprintf( __( '%s became a registered member', 'buddypress' ), $userlink );
-
-       // Legacy filter - pass $user_id instead of $activity
-       if ( has_filter( 'bp_core_activity_registered_member_action' ) ) {
-               $action = apply_filters( 'bp_core_activity_registered_member_action', $action, $activity->user_id );
-       }
-
-       return apply_filters( 'bp_xprofile_format_activity_action_new_member', $action, $activity );
-}
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px">  * Format 'updated_profile' activity actions.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since BuddyPress (2.0.0)
</span></span></pre></div>
<a id="trunktestsphpunittestcasesmembersactivityphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/testcases/members/activity.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/members/activity.php                                (rev 0)
+++ trunk/tests/phpunit/testcases/members/activity.php  2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,77 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * @group members
+ * @group activity
+ */
+class BP_Tests_Members_Activity extends BP_UnitTestCase {
+
+       /**
+        * @group activity_action
+        * @group bp_core_format_activity_action_new_member
+        */
+       public function test_bp_members_format_activity_action_new_member() {
+               $u = $this->factory->user->create();
+               $a = $this->factory->activity->create( array(
+                       'component' => buddypress()->members->id,
+                       'type' => 'new_member',
+                       'user_id' => $u,
+               ) );
+
+               $expected = sprintf( __( '%s became a registered member', 'buddypress' ), bp_core_get_userlink( $u ) );
+
+               $a_obj = new BP_Activity_Activity( $a );
+
+               $this->assertSame( $expected, $a_obj->action );
+       }
+
+       /**
+        * @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 );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestcasesxprofileactivityphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/xprofile/activity.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/xprofile/activity.php       2014-12-24 02:32:14 UTC (rev 9272)
+++ trunk/tests/phpunit/testcases/xprofile/activity.php 2014-12-24 04:35:52 UTC (rev 9273)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -293,58 +293,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @group activity_action
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group bp_xprofile_format_activity_action_new_member
-        */
-       public function test_bp_xprofile_format_activity_action_new_member_xprofile_on() {
-               $active = bp_is_active( 'xprofile' );
-               buddypress()->active_components['xprofile'] = '1';
-
-               $u = $this->factory->user->create();
-               $a = $this->factory->activity->create( array(
-                       'component' => buddypress()->profile->id,
-                       'type' => 'new_member',
-                       'user_id' => $u,
-               ) );
-
-               $expected = sprintf( __( '%s became a registered member', 'buddypress' ), bp_core_get_userlink( $u ) );
-
-               $a_obj = new BP_Activity_Activity( $a );
-
-               $this->assertSame( $expected, $a_obj->action );
-
-               if ( ! $active ) {
-                       unset( buddypress()->active_components['xprofile'] );
-               }
-       }
-
-       /**
-        * @group activity_action
-        * @group bp_xprofile_format_activity_action_new_member
-        */
-       public function test_bp_xprofile_format_activity_action_new_member_xprofile_off() {
-               $active = bp_is_active( 'xprofile' );
-               unset( buddypress()->active_components['xprofile'] );
-
-               $u = $this->factory->user->create();
-               $a = $this->factory->activity->create( array(
-                       'component' => buddypress()->profile->id,
-                       'type' => 'new_member',
-                       'user_id' => $u,
-               ) );
-
-               $expected = sprintf( __( '%s became a registered member', 'buddypress' ), bp_core_get_userlink( $u ) );
-
-               $a_obj = new BP_Activity_Activity( $a );
-
-               $this->assertSame( $expected, $a_obj->action );
-
-               if ( $active ) {
-                       buddypress()->active_components['xprofile'] = '1';
-               }
-       }
-
-       /**
-        * @group activity_action
</del><span class="cx" style="display: block; padding: 0 10px">          * @group bp_xprofile_format_activity_action_updated_profile
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_bp_xprofile_format_activity_action_updated_profile() {
</span></span></pre>
</div>
</div>

</body>
</html>