Skip to:
Content

BuddyPress.org

Changeset 12420


Ignore:
Timestamp:
08/01/2019 05:41:55 AM (7 weeks ago)
Author:
imath
Message:

Make sure activity comments action strings are generated at run-time

Fixes #8120

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r12153 r12420  
    15401540                $descendants    = self::get_activity_data( $descendant_ids );
    15411541                $descendants    = self::append_user_fullnames( $descendants );
     1542                $descendants    = self::generate_action_strings( $descendants );
    15421543            }
    15431544
  • trunk/tests/phpunit/testcases/activity/functions.php

    r12246 r12420  
    752752
    753753        $this->assertSame( $expected, $a_obj->action );
     754    }
     755
     756    /**
     757     * @group activity_action
     758     * @group bp_activity_format_activity_action_activity_comment
     759     * @ticket BP8120
     760     */
     761    public function test_bp_activity_format_activity_action_children_activity_comment() {
     762        $u = self::factory()->user->create();
     763        $a1 = self::factory()->activity->create( array(
     764            'component' => buddypress()->activity->id,
     765            'type'      => 'activity_update',
     766            'user_id'   => $u,
     767        ) );
     768
     769        $ac1 = self::factory()->activity->create( array(
     770            'type'              => 'activity_comment',
     771            'item_id'           => $a1,
     772            'secondary_item_id' => $a1,
     773            'user_id'           => $u,
     774        ) );
     775
     776        $ac2 = self::factory()->activity->create( array(
     777            'type'              => 'activity_comment',
     778            'item_id'           => $a1,
     779            'secondary_item_id' => $ac1,
     780            'user_id'           => $u,
     781        ) );
     782
     783        // Remove all action strings
     784        $table = buddypress()->activity->table_name;
     785        $GLOBALS['wpdb']->query( "UPDATE {$table} set action = '' WHERE id IN ( {$a1}, {$ac1}, {$ac2} )" );
     786
     787        $get = bp_activity_get( array(
     788            'in'               => array( $a1 ),
     789            'display_comments' => 'thread'
     790        ) );
     791
     792        $activity    = reset( $get['activities'] );
     793        $comment_one = reset( $activity->children );
     794        $comment_two = reset( $comment_one->children );
     795        $user_link   = bp_core_get_userlink( $u );
     796
     797        $this->assertSame( sprintf( '%s posted a new activity comment', $user_link ), $comment_one->action );
     798        $this->assertSame( sprintf( '%s posted a new activity comment', $user_link ), $comment_two->action );
    754799    }
    755800
Note: See TracChangeset for help on using the changeset viewer.