Skip to:
Content

BuddyPress.org

Changeset 7047


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.

Location:
trunk/tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/includes/factory.php

    r6905 r7047  
    3131            $args['user_id'] = get_current_user_id();
    3232
    33         return $this->get_object_by_id( bp_activity_add( $args ) );
     33        return bp_activity_add( $args );
    3434    }
    3535
  • trunk/tests/testcases/activity/class.BP_Activity_Activity.php

    r7039 r7047  
    2626
    2727        $result = BP_Activity_Activity::check_exists_by_content( $content );
    28         $this->assertEquals( $activity->id, $result );
     28        $this->assertEquals( $activity, $result );
    2929    }
    3030
     
    3939        ) );
    4040
    41         BP_Activity_Activity::delete_activity_item_comments( $parent_activity->id );
     41        BP_Activity_Activity::delete_activity_item_comments( $parent_activity );
    4242
    4343        $result = BP_Activity_Activity::get( array( 'in' => wp_list_pluck( $comments, 'id' ), ) );
     
    5353        ) );
    5454
    55         bp_activity_update_meta( $activity->id, 'Paul', 'is cool' );
    56         BP_Activity_Activity::delete_activity_meta_entries( $activity->id );
     55        bp_activity_update_meta( $activity, 'Paul', 'is cool' );
     56        BP_Activity_Activity::delete_activity_meta_entries( $activity );
    5757
    58         $meta = bp_activity_get_meta( $activity->id, 'Paul' );
     58        $meta = bp_activity_get_meta( $activity, 'Paul' );
    5959        $this->assertFalse( $meta );
    6060    }
     
    6868
    6969        $activity = BP_Activity_Activity::get( array(
    70             'in'          => $activity->id,
     70            'in'          => $activity,
    7171            'show_hidden' => true,
    7272        ) );
     
    7777        $a1 = $this->factory->activity->create();
    7878        $a2 = $this->factory->activity->create();
    79         bp_activity_update_meta( $a1->id, 'foo', 'bar' );
     79        bp_activity_update_meta( $a1, 'foo', 'bar' );
    8080
    8181        $activity = BP_Activity_Activity::get( array(
     
    8888        ) );
    8989        $ids = wp_list_pluck( $activity['activities'], 'id' );
    90         $this->assertEquals( $ids, array( $a1->id ) );
     90        $this->assertEquals( $ids, array( $a1 ) );
    9191    }
    9292}
  • 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}
  • trunk/tests/testcases/routing/activity.php

    r7039 r7047  
    2828     */
    2929    function test_activity_permalink() {
    30         $activity = $this->factory->activity->create();
     30        $a = $this->factory->activity->create();
     31        $activity = $this->factory->activity->get_object_by_id( $a );
    3132
    3233        $url = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
Note: See TracChangeset for help on using the changeset viewer.