Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/09/2013 02:11:52 PM (12 years ago)
Author:
boonebgorges
Message:

In test suite, factory->activity->create() should return an id, not an object

Two reasons: The value that's almost always needed is an ID, and it's more
consistent with WP's factories.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/template.php

    r6948 r7047  
    2424        global $bp;
    2525
    26         $activity = $this->factory->activity->create( array(
     26        $a = $this->factory->activity->create( array(
    2727            'type' => 'activity_update',
    2828        ) );
    2929
    3030        // User can delete his own items
     31        $activity = $this->factory->activity->get_object_by_id( $a );
    3132        $this->assertTrue( bp_activity_user_can_delete( $activity ) );
    3233
     
    7576        ) );
    7677
    77         bp_activity_add_user_favorite( $a1->id, $user_id );
    78         bp_activity_add_user_favorite( $a2->id, $user_id );
     78        bp_activity_add_user_favorite( $a1, $user_id );
     79        bp_activity_add_user_favorite( $a2, $user_id );
    7980
    8081        // groan. It sucks that you have to invoke the global
     
    9293        $ids = wp_list_pluck( $activities_template->activities, 'id' );
    9394
    94         $this->assertEquals( $ids, array( $a1->id, $a2->id ) );
     95        $this->assertEquals( $ids, array( $a1, $a2 ) );
    9596
    9697        $activities_template = null;
     
    107108        $ids = wp_list_pluck( $activities_template->activities, 'id' );
    108109
    109         $this->assertEquals( $ids, array( $a1->id ) );
     110        $this->assertEquals( $ids, array( $a1 ) );
    110111
    111112        $activities_template = null;
     
    118119        $a1 = $this->factory->activity->create();
    119120        $a2 = $this->factory->activity->create();
    120         bp_activity_update_meta( $a1->id, 'foo', 'bar' );
     121        bp_activity_update_meta( $a1, 'foo', 'bar' );
    121122
    122123        global $activities_template;
     
    131132
    132133        $ids = wp_list_pluck( $activities_template->activities, 'id' );
    133         $this->assertEquals( $ids, array( $a1->id ) );
     134        $this->assertEquals( $ids, array( $a1 ) );
    134135    }
    135136}
Note: See TracChangeset for help on using the changeset viewer.