Skip to:
Content

BuddyPress.org

Changeset 9121


Ignore:
Timestamp:
11/03/2014 06:26:26 PM (9 years ago)
Author:
djpaul
Message:

Groups, Unit Tests: a creator_id must be passed to groups_create_group to create a group.

Some of our unit tests were built to assume that they would always run with an authenticated user, but obviously this was incorrect. As a result, Groups were being created with creator_id=0, which was breaking other parts of the codebase, for certain tests.

This change also removes the test_creating_new_group_as_anonymous_user test that I added in r9118 which is now unnecessary.

See r9117, r9118, r9120 for other parts of this fix.
Fixes #5983 and the unit tests. :)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-functions.php

    r9027 r9121  
    121121
    122122    // Set creator ID
    123     if ( ! empty( $creator_id ) ) {
     123    if ( $creator_id ) {
    124124        $group->creator_id = (int) $creator_id;
    125     } else {
     125    } elseif ( is_user_logged_in() ) {
    126126        $group->creator_id = bp_loggedin_user_id();
     127    }
     128
     129    if ( ! $group->creator_id ) {
     130        return false;
    127131    }
    128132
  • trunk/tests/phpunit/testcases/groups/functions.php

    r9118 r9121  
    1616
    1717        $this->factory->group->create();
    18     }
    19 
    20     public function test_creating_new_group_as_anonymous_user() {
    21         $g = $this->factory->group->create();
    22         $this->assertFalse( $g );
    2318    }
    2419
Note: See TracChangeset for help on using the changeset viewer.