Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/29/2014 04:04:42 PM (10 years ago)
Author:
boonebgorges
Message:

Create an activity item when a group's details are updated.

When a name or description alone are updated, the activity item will display
the "from" and "to" values as part of the formatted activity action string. If
both items have been changed, the activity action will read "x changed the name
and description of the group y".

Fixes #5880.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/activity.php

    r9139 r9204  
    4949        $this->assertSame( $expected, $a_obj->action );
    5050    }
     51
     52    /**
     53     * @group activity_action
     54     * @group bp_groups_format_activity_action_group_details_updated
     55     */
     56    public function test_bp_groups_format_activity_action_group_details_updated_with_no_change() {
     57        $group = $this->factory->group->create_and_get();
     58        groups_edit_base_group_details( $group->id, $group->name, $group->description, true );
     59
     60        $a = bp_activity_get( array(
     61            'component' => buddypress()->groups->id,
     62            'action' => 'group_details_updated',
     63            'item_id' => $group->id,
     64        ) );
     65
     66        $this->assertTrue( empty( $a['activities'] ) );
     67    }
     68
     69    /**
     70     * @group activity_action
     71     * @group bp_groups_format_activity_action_group_details_updated
     72     */
     73    public function test_bp_groups_format_activity_action_group_details_updated_with_notify_members_false() {
     74        $group = $this->factory->group->create_and_get();
     75        groups_edit_base_group_details( $group->id, 'Foo', $group->description, false );
     76
     77        $a = bp_activity_get( array(
     78            'component' => buddypress()->groups->id,
     79            'action' => 'group_details_updated',
     80            'item_id' => $group->id,
     81        ) );
     82
     83        $this->assertTrue( empty( $a['activities'] ) );
     84    }
     85
     86    /**
     87     * @group activity_action
     88     * @group bp_groups_format_activity_action_group_details_updated
     89     */
     90    public function test_bp_groups_format_activity_action_group_details_updated_with_updated_name() {
     91        $old_user = get_current_user_id();
     92        $u = $this->factory->user->create();
     93        $this->set_current_user( $u );
     94
     95        $group = $this->factory->group->create_and_get();
     96        groups_edit_base_group_details( $group->id, 'Foo', $group->description, true );
     97
     98        $a = bp_activity_get( array(
     99            'component' => buddypress()->groups->id,
     100            'action' => 'group_details_updated',
     101            'item_id' => $group->id,
     102        ) );
     103
     104        $this->assertNotEmpty( $a['activities'] );
     105
     106        $expected = sprintf( __( '%s changed the name of the group %s from "%s" to "%s"', 'buddypress' ), bp_core_get_userlink( $u ),  '<a href="' . bp_get_group_permalink( $group ) . '">Foo</a>', $group->name, 'Foo' );
     107        $this->assertSame( $expected, $a['activities'][0]->action );
     108
     109        $this->set_current_user( $old_user );
     110    }
     111
     112    /**
     113     * @group activity_action
     114     * @group bp_groups_format_activity_action_group_details_updated
     115     */
     116    public function test_bp_groups_format_activity_action_group_details_updated_with_updated_description() {
     117        $old_user = get_current_user_id();
     118        $u = $this->factory->user->create();
     119        $this->set_current_user( $u );
     120
     121        $group = $this->factory->group->create_and_get();
     122        groups_edit_base_group_details( $group->id, $group->name, 'Bar', true );
     123
     124        $a = bp_activity_get( array(
     125            'component' => buddypress()->groups->id,
     126            'action' => 'group_details_updated',
     127            'item_id' => $group->id,
     128        ) );
     129
     130        $this->assertNotEmpty( $a['activities'] );
     131
     132        $expected = sprintf( __( '%s changed the description of the group %s from "%s" to "%s"', 'buddypress' ), bp_core_get_userlink( $u ),  '<a href="' . bp_get_group_permalink( $group ) . '">' . $group->name . '</a>', $group->description, 'Bar' );
     133        $this->assertSame( $expected, $a['activities'][0]->action );
     134
     135        $this->set_current_user( $old_user );
     136    }
     137
     138    /**
     139     * @group activity_action
     140     * @group bp_groups_format_activity_action_group_details_updated
     141     */
     142    public function test_bp_groups_format_activity_action_group_details_updated_with_updated_name_and_description() {
     143        $old_user = get_current_user_id();
     144        $u = $this->factory->user->create();
     145        $this->set_current_user( $u );
     146
     147        $group = $this->factory->group->create_and_get();
     148        groups_edit_base_group_details( $group->id, 'Foo', 'Bar', true );
     149
     150        $a = bp_activity_get( array(
     151            'component' => buddypress()->groups->id,
     152            'action' => 'group_details_updated',
     153            'item_id' => $group->id,
     154        ) );
     155
     156        $this->assertNotEmpty( $a['activities'] );
     157
     158        $expected = sprintf( __( '%s changed the name and description of the group %s', 'buddypress' ), bp_core_get_userlink( $u ),  '<a href="' . bp_get_group_permalink( $group ) . '">Foo</a>' );
     159        $this->assertSame( $expected, $a['activities'][0]->action );
     160
     161        $this->set_current_user( $old_user );
     162    }
    51163}
Note: See TracChangeset for help on using the changeset viewer.