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/functions.php

    r9137 r9139  
    1919
    2020    public function test_creating_new_group_as_authenticated_user() {
    21         $u = $this->create_user();
     21        $u = $this->factory->user->create();
    2222        wp_set_current_user( $u );
    2323
     
    3030     */
    3131    public function test_total_group_count_groups_join_group() {
    32         $u1 = $this->create_user();
    33         $u2 = $this->create_user();
     32        $u1 = $this->factory->user->create();
     33        $u2 = $this->factory->user->create();
    3434        $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    3535
     
    4343     */
    4444    public function test_total_group_count_groups_leave_group() {
    45         $u1 = $this->create_user();
    46         $u2 = $this->create_user();
     45        $u1 = $this->factory->user->create();
     46        $u2 = $this->factory->user->create();
    4747        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    4848        $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     
    5959     */
    6060    public function test_total_group_count_groups_ban_member() {
    61         $u1 = $this->create_user();
    62         $u2 = $this->create_user();
     61        $u1 = $this->factory->user->create();
     62        $u2 = $this->factory->user->create();
    6363        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    6464        $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     
    8080     */
    8181    public function test_total_group_count_groups_unban_member() {
    82         $u1 = $this->create_user();
    83         $u2 = $this->create_user();
     82        $u1 = $this->factory->user->create();
     83        $u2 = $this->factory->user->create();
    8484        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    8585        $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     
    103103     */
    104104    public function test_total_group_count_groups_accept_invite() {
    105         $u1 = $this->create_user();
    106         $u2 = $this->create_user();
     105        $u1 = $this->factory->user->create();
     106        $u2 = $this->factory->user->create();
    107107        $g = $this->factory->group->create();
    108108        groups_invite_user( array(
     
    122122     */
    123123    public function test_total_group_count_groups_accept_membership_request() {
    124         $u = $this->create_user();
     124        $u = $this->factory->user->create();
    125125        $g = $this->factory->group->create();
    126126        groups_send_membership_request( $u, $g );
     
    136136     */
    137137    public function test_total_group_count_groups_remove_member() {
    138         $u1 = $this->create_user();
    139         $u2 = $this->create_user();
     138        $u1 = $this->factory->user->create();
     139        $u2 = $this->factory->user->create();
    140140        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    141141        $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     
    157157     */
    158158    public function test_total_member_count_groups_join_group() {
    159         $u1 = $this->create_user();
    160         $u2 = $this->create_user();
     159        $u1 = $this->factory->user->create();
     160        $u2 = $this->factory->user->create();
    161161        $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    162162
     
    170170     */
    171171    public function test_total_member_count_groups_leave_group() {
    172         $u1 = $this->create_user();
     172        $u1 = $this->factory->user->create();
    173173        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    174174        groups_join_group( $g1, $u1 );
     
    183183     */
    184184    public function test_total_member_count_groups_ban_member() {
    185         $u1 = $this->create_user();
    186         $u2 = $this->create_user();
     185        $u1 = $this->factory->user->create();
     186        $u2 = $this->factory->user->create();
    187187        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    188188        groups_join_group( $g1, $u2 );
     
    202202     */
    203203    public function test_total_member_count_groups_unban_member() {
    204         $u1 = $this->create_user();
    205         $u2 = $this->create_user();
     204        $u1 = $this->factory->user->create();
     205        $u2 = $this->factory->user->create();
    206206        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    207207        groups_join_group( $g1, $u2 );
     
    223223     */
    224224    public function test_total_member_count_groups_accept_invite() {
    225         $u1 = $this->create_user();
    226         $u2 = $this->create_user();
     225        $u1 = $this->factory->user->create();
     226        $u2 = $this->factory->user->create();
    227227        $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    228228        groups_invite_user( array(
     
    242242     */
    243243    public function test_total_member_count_groups_accept_membership_request() {
    244         $u1 = $this->create_user();
    245         $u2 = $this->create_user();
     244        $u1 = $this->factory->user->create();
     245        $u2 = $this->factory->user->create();
    246246        $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    247247
     
    257257     */
    258258    public function test_total_member_count_groups_remove_member() {
    259         $u1 = $this->create_user();
    260         $u2 = $this->create_user();
     259        $u1 = $this->factory->user->create();
     260        $u2 = $this->factory->user->create();
    261261        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    262262        groups_join_group( $g1, $u2 );
     
    276276     */
    277277    public function test_total_member_count_groups_create_group() {
    278         $u1 = $this->create_user();
     278        $u1 = $this->factory->user->create();
    279279        $g = groups_create_group( array(
    280280            'creator_id' => $u1,
     
    602602    public function test_groups_get_group_cache_different_users() {
    603603        $g = $this->factory->group->create();
    604         $u1 = $this->create_user();
    605         $u2 = $this->create_user();
     604        $u1 = $this->factory->user->create();
     605        $u2 = $this->factory->user->create();
    606606        $this->add_user_to_group( $u1, $g );
    607607
     
    624624     */
    625625    public function test_get_invite_count_for_user() {
    626         $u1 = $this->create_user();
    627         $u2 = $this->create_user();
     626        $u1 = $this->factory->user->create();
     627        $u2 = $this->factory->user->create();
    628628        $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
    629629
Note: See TracChangeset for help on using the changeset viewer.