Skip to:
Content

BuddyPress.org

Changeset 9366


Ignore:
Timestamp:
01/16/2015 10:02:01 AM (10 years ago)
Author:
djpaul
Message:

Activity: make sure activity actions are set when creating activity objects.

We can't assume it will already be set because this is normally only done on an ad-hoc basis.
Running certain unit tests in isolation revealed this issue.

Fixes #6126, props imath

Location:
trunk
Files:
2 edited

Legend:

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

    r9351 r9366  
    162162            $this->is_spam           = $row->is_spam;
    163163        }
     164
     165        /**
     166         * Make sure the activity actions have been registered.
     167         * We can't assume it will already be set because this is normally only done on an ad-hoc basis.
     168         *
     169         * @link https://buddypress.trac.wordpress.org/ticket/6126
     170         */
     171        bp_activity_get_actions();
    164172
    165173        // Generate dynamic 'action' when possible
  • trunk/tests/phpunit/testcases/blogs/activity.php

    r9194 r9366  
    284284        $this->assertEquals( $this->comment_post_id, $p );
    285285    }
     286
     287    /**
     288     * @ticket BP6126
     289     */
     290    public function test_check_activity_actions_are_set_when_creating_activity_object() {
     291        $bp = buddypress();
     292
     293        if ( isset( $bp->activity->actions ) ) {
     294            unset( $bp->activity->actions );
     295        }
     296
     297        $u = $this->factory->user->create();
     298        $p = $this->factory->post->create( array( 'post_author' => $u, ) );
     299        $a = $this->factory->activity->create( array(
     300            'component'         => buddypress()->blogs->id,
     301            'item_id'           => 1,
     302            'secondary_item_id' => $p,
     303            'type'              => 'new_blog_post',
     304            'user_id'           => $u,
     305        ) );
     306
     307        $a_obj = new BP_Activity_Activity( $a );
     308        $this->assertTrue( ! empty( $a_obj->action ) );
     309
     310    }
     311
    286312    /**
    287313     * Dopey passthrough method so we can check that the correct values
Note: See TracChangeset for help on using the changeset viewer.