Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/14/2014 02:01:18 PM (9 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/members/template.php

    r9045 r9139  
    2121
    2222    public function test_bp_has_members_include_on_user_page() {
    23         $u1 = $this->create_user();
    24         $u2 = $this->create_user();
     23        $u1 = $this->factory->user->create();
     24        $u2 = $this->factory->user->create();
    2525
    2626        $this->go_to( bp_core_get_user_domain( $u1 ) );
     
    4646     */
    4747    public function test_bp_has_members_search_pagination_with_spaces() {
    48         $u1 = $this->create_user( array( 'display_name' => '~ tilde u1' ) );
    49         $u2 = $this->create_user( array( 'display_name' => '~ tilde u2' ) );
     48        $u1 = $this->factory->user->create( array( 'display_name' => '~ tilde u1' ) );
     49        $u2 = $this->factory->user->create( array( 'display_name' => '~ tilde u2' ) );
    5050
    5151        $template_args = array(
     
    6868
    6969    public function test_bp_has_members_friendship_requests() {
    70         $u1 = $this->create_user();
    71         $u2 = $this->create_user();
     70        $u1 = $this->factory->user->create();
     71        $u2 = $this->factory->user->create();
    7272
    7373        friends_add_friend( $u1, $u2 );
     
    9797     */
    9898    public function test_bp_has_members_friendship_requests_with_no_requests() {
    99         $u1 = $this->create_user();
    100         $u2 = $this->create_user();
     99        $u1 = $this->factory->user->create();
     100        $u2 = $this->factory->user->create();
    101101
    102102        $old_user = get_current_user_id();
Note: See TracChangeset for help on using the changeset viewer.