Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/14/2014 02:01:18 PM (10 years ago)
Author:
boonebgorges
Message:

In automated tests, move user creation to a proper factory method.

BP user creation requires that a couple of extra pieces of data be set up
(last activity, display name, etc). So we previously had a wrapper in
BP_UnitTestCase called create_user() that performed the extra setup.
However, the wrapper made it impossible to use create_user() statically,
because the user_login and user_email iterator was not persistent from call to
call. (The create_user() syntax is also a break with the rest of our unit
tests, which is not ideal.)

This changeset introduces BP_UnitTest_Factory_For_User, which reproduces the
customizations of create_user(), but in a proper factory method. All
instances of create_user() throughout the test suite have also been replaced.

See #6009.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php

    r8958 r9139  
    293293
    294294        // Test as group member
    295         $u = $this->create_user();
     295        $u = $this->factory->user->create();
    296296        $this->set_current_user( $u );
    297297        $this->add_user_to_group( $u, $g );
     
    336336
    337337        // Test as group member
    338         $u = $this->create_user();
     338        $u = $this->factory->user->create();
    339339        $this->set_current_user( $u );
    340340        $this->add_user_to_group( $u, $g );
     
    422422        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    423423
    424         $u = $this->create_user();
     424        $u = $this->factory->user->create();
    425425        $old_current_user = get_current_user_id();
    426426        $this->set_current_user( $u );
     
    464464        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    465465
    466         $u = $this->create_user();
     466        $u = $this->factory->user->create();
    467467        $old_current_user = get_current_user_id();
    468468        $this->set_current_user( $u );
     
    508508        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    509509
    510         $u = $this->create_user();
     510        $u = $this->factory->user->create();
    511511        $old_current_user = get_current_user_id();
    512512        $this->set_current_user( $u );
     
    554554        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    555555
    556         $u = $this->create_user();
     556        $u = $this->factory->user->create();
    557557        $old_current_user = get_current_user_id();
    558558        $this->set_current_user( $u );
     
    682682        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    683683
    684         $u = $this->create_user();
     684        $u = $this->factory->user->create();
    685685        $old_current_user = get_current_user_id();
    686686        $this->set_current_user( $u );
     
    724724        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    725725
    726         $u = $this->create_user();
     726        $u = $this->factory->user->create();
    727727        $old_current_user = get_current_user_id();
    728728        $this->set_current_user( $u );
     
    768768        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    769769
    770         $u = $this->create_user();
     770        $u = $this->factory->user->create();
    771771        $old_current_user = get_current_user_id();
    772772        $this->set_current_user( $u );
     
    814814        $g_obj = groups_get_group( array( 'group_id' => $g ) );
    815815
    816         $u = $this->create_user();
     816        $u = $this->factory->user->create();
    817817        $old_current_user = get_current_user_id();
    818818        $this->set_current_user( $u );
Note: See TracChangeset for help on using the changeset viewer.