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/core/class-bp-button.php

    r8958 r9139  
    2222     */
    2323    public function test_block_self_own_profile() {
    24         $u = $this->create_user();
     24        $u = $this->factory->user->create();
    2525        $this->set_current_user( $u );
    2626
     
    4040     */
    4141    public function test_block_self_others_profile() {
    42         $u1 = $this->create_user();
     42        $u1 = $this->factory->user->create();
    4343        $this->set_current_user( $u1 );
    4444
    45         $u2 = $this->create_user();
     45        $u2 = $this->factory->user->create();
    4646        $this->go_to( bp_core_get_user_domain( $u2 ) );
    4747
     
    6060    public function test_block_self_inside_members_loop() {
    6161        $now = time();
    62         $u1 = $this->create_user( array(
     62        $u1 = $this->factory->user->create( array(
    6363            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    6464        ) );
    65         $u2 = $this->create_user( array(
     65        $u2 = $this->factory->user->create( array(
    6666            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    6767        ) );
     
    100100    public function test_block_self_false_inside_members_loop() {
    101101        $now = time();
    102         $u1 = $this->create_user( array(
     102        $u1 = $this->factory->user->create( array(
    103103            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    104104        ) );
    105         $u2 = $this->create_user( array(
     105        $u2 = $this->factory->user->create( array(
    106106            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    107107        ) );
     
    140140    public function test_block_self_inside_members_loop_on_my_profile_page() {
    141141        $now = time();
    142         $u1 = $this->create_user( array(
     142        $u1 = $this->factory->user->create( array(
    143143            'last_activity' => date( 'Y-m-d H:i:s', $now ),
    144144        ) );
    145         $u2 = $this->create_user( array(
     145        $u2 = $this->factory->user->create( array(
    146146            'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),
    147147        ) );
Note: See TracChangeset for help on using the changeset viewer.