Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (7 years ago)
Author:
boonebgorges
Message:

Use static factory method throughout PHPUnit tests.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/friends/class-bp-friends-friendship.php

    r11122 r11737  
    66class BP_Tests_BP_Friends_Friendship_TestCases extends BP_UnitTestCase {
    77    public function test_search_friends() {
    8         $u1 = $this->factory->user->create();
    9         $u2 = $this->factory->user->create();
    10         $u3 = $this->factory->user->create();
     8        $u1 = self::factory()->user->create();
     9        $u2 = self::factory()->user->create();
     10        $u3 = self::factory()->user->create();
    1111
    1212        xprofile_set_field_data( 1, $u2, 'Cool Dude' );
     
    2626        $this->deactivate_component( 'xprofile' );
    2727
    28         $u1 = $this->factory->user->create();
    29         $u2 = $this->factory->user->create();
    30         $u3 = $this->factory->user->create();
     28        $u1 = self::factory()->user->create();
     29        $u2 = self::factory()->user->create();
     30        $u3 = self::factory()->user->create();
    3131
    3232        add_user_meta( $u2, 'nickname', 'Cool Dude' );
     
    4141
    4242    public function test_get_bulk_last_active() {
    43         $u1 = $this->factory->user->create( array(
     43        $u1 = self::factory()->user->create( array(
    4444            'last_activity' => gmdate( 'Y-m-d H:i:s' ),
    4545        ) );
    46         $u2 = $this->factory->user->create( array(
     46        $u2 = self::factory()->user->create( array(
    4747            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
    4848        ) );
    49         $u3 = $this->factory->user->create( array(
     49        $u3 = self::factory()->user->create( array(
    5050            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 50 ),
    5151        ) );
     
    5757
    5858    public function test_search_users() {
    59         $u1 = $this->factory->user->create();
    60         $u2 = $this->factory->user->create();
    61         $u3 = $this->factory->user->create();
     59        $u1 = self::factory()->user->create();
     60        $u2 = self::factory()->user->create();
     61        $u3 = self::factory()->user->create();
    6262
    6363        xprofile_set_field_data( 1, $u1, 'Freedom Isn\'t Free' );
     
    7171
    7272    public function test_search_users_count() {
    73         $u1 = $this->factory->user->create();
    74         $u2 = $this->factory->user->create();
    75         $u3 = $this->factory->user->create();
     73        $u1 = self::factory()->user->create();
     74        $u2 = self::factory()->user->create();
     75        $u3 = self::factory()->user->create();
    7676
    7777        xprofile_set_field_data( 1, $u1, 'Freedom Isn\'t Free' );
     
    8888     */
    8989    public function test_check_is_friend_not_friends() {
    90         $u1 = $this->factory->user->create();
    91         $u2 = $this->factory->user->create();
     90        $u1 = self::factory()->user->create();
     91        $u2 = self::factory()->user->create();
    9292        $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
    9393    }
     
    9797     */
    9898    public function test_check_is_friend_pending() {
    99         $u1 = $this->factory->user->create();
    100         $u2 = $this->factory->user->create();
     99        $u1 = self::factory()->user->create();
     100        $u2 = self::factory()->user->create();
    101101        friends_add_friend( $u1, $u2, false );
    102102        $this->assertEquals( 'pending', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     
    107107     */
    108108    public function test_check_is_friend_awaiting_response() {
    109         $u1 = $this->factory->user->create();
    110         $u2 = $this->factory->user->create();
     109        $u1 = self::factory()->user->create();
     110        $u2 = self::factory()->user->create();
    111111        friends_add_friend( $u1, $u2, false );
    112112        $this->assertEquals( 'awaiting_response', BP_Friends_Friendship::check_is_friend( $u2, $u1 ) );
     
    117117     */
    118118    public function test_check_is_friend_is_friend() {
    119         $u1 = $this->factory->user->create();
    120         $u2 = $this->factory->user->create();
     119        $u1 = self::factory()->user->create();
     120        $u2 = self::factory()->user->create();
    121121        friends_add_friend( $u1, $u2, true );
    122122        $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
     
    127127     */
    128128    public function test_save_method_should_update_existing_row() {
    129         $u1 = $this->factory->user->create();
    130         $u2 = $this->factory->user->create();
     129        $u1 = self::factory()->user->create();
     130        $u2 = self::factory()->user->create();
    131131
    132132        $friendship = new BP_Friends_Friendship();
     
    155155        global $wpdb;
    156156        $now = time();
    157         $u1 = $this->factory->user->create( array(
     157        $u1 = self::factory()->user->create( array(
    158158            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    159159        ) );
    160         $u2 = $this->factory->user->create( array(
     160        $u2 = self::factory()->user->create( array(
    161161            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    162162        ) );
Note: See TracChangeset for help on using the changeset viewer.