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

    r9123 r9139  
    9696     */
    9797    public function test_bp_core_get_user_displayname_translate_username() {
    98         $u = $this->create_user();
     98        $u = $this->factory->user->create();
    9999
    100100        $user = new WP_User( $u );
     
    120120        buddypress()->active_components['xprofile'] = '1';
    121121
    122         $u = $this->create_user( array(
     122        $u = $this->factory->user->create( array(
    123123            'display_name' => 'Foo',
    124124        ) );
     
    140140        buddypress()->active_components['xprofile'] = '1';
    141141
    142         $u = $this->create_user();
     142        $u = $this->factory->user->create();
    143143        xprofile_set_field_data( 1, $u, 'Foo Foo' );
    144144
     
    157157        buddypress()->active_components['xprofile'] = '1';
    158158
    159         $u = $this->create_user();
     159        $u = $this->factory->user->create();
    160160        xprofile_set_field_data( 1, $u, 'Foo Foo' );
    161161
     
    174174        buddypress()->active_components['xprofile'] = '1';
    175175
    176         $u = $this->create_user( array(
     176        $u = $this->factory->user->create( array(
    177177            'display_name' => 'Foo Foo',
    178178        ) );
     
    205205     */
    206206    public function test_bp_core_get_user_displaynames_all_uncached() {
    207         $u1 = $this->create_user();
    208         $u2 = $this->create_user();
     207        $u1 = $this->factory->user->create();
     208        $u2 = $this->factory->user->create();
    209209
    210210        xprofile_set_field_data( 1, $u1, 'Foo' );
     
    223223     */
    224224    public function test_bp_core_get_user_displaynames_one_not_in_xprofile() {
    225         $u1 = $this->create_user();
    226         $u2 = $this->create_user( array(
     225        $u1 = $this->factory->user->create();
     226        $u2 = $this->factory->user->create( array(
    227227            'display_name' => 'Bar',
    228228        ) );
     
    249249     */
    250250    public function test_bp_core_get_user_displaynames_one_in_cache() {
    251         $u1 = $this->create_user();
     251        $u1 = $this->factory->user->create();
    252252        xprofile_set_field_data( 1, $u1, 'Foo' );
    253253
     
    268268     */
    269269    public function test_bp_members_migrate_signups_standard() {
    270         $u = $this->create_user();
     270        $u = $this->factory->user->create();
    271271        $u_obj = new WP_User( $u );
    272272
     
    302302     */
    303303    public function test_bp_members_migrate_signups_activation_key_but_user_status_0() {
    304         $u = $this->create_user();
     304        $u = $this->factory->user->create();
    305305        $u_obj = new WP_User( $u );
    306306
     
    333333     */
    334334    public function test_bp_members_migrate_signups_no_activation_key_but_user_status_2() {
    335         $u = $this->create_user();
     335        $u = $this->factory->user->create();
    336336        $u_obj = new WP_User( $u );
    337337
Note: See TracChangeset for help on using the changeset viewer.