Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/14/2014 02:01:18 PM (12 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/xprofile/functions.php

    r9073 r9139  
    1515
    1616        public function test_get_hidden_field_types_for_user_loggedout() {
    17                 $duser = $this->create_user();
     17                $duser = $this->factory->user->create();
    1818
    1919                $old_current_user = bp_loggedin_user_id();
     
    2626
    2727        public function test_get_hidden_field_types_for_user_loggedin() {
    28                 $duser = $this->create_user();
    29                 $cuser = $this->create_user();
     28                $duser = $this->factory->user->create();
     29                $cuser = $this->factory->user->create();
    3030
    3131                $old_current_user = bp_loggedin_user_id();
     
    3838
    3939        public function test_get_hidden_field_types_for_user_friends() {
    40                 $duser = $this->create_user();
    41                 $cuser = $this->create_user();
     40                $duser = $this->factory->user->create();
     41                $cuser = $this->factory->user->create();
    4242                friends_add_friend( $duser, $cuser, true );
    4343
     
    5151
    5252        public function test_get_hidden_field_types_for_user_admin() {
    53                 $duser = $this->create_user();
    54                 $cuser = $this->create_user();
     53                $duser = $this->factory->user->create();
     54                $cuser = $this->factory->user->create();
    5555                $this->grant_bp_moderate( $cuser );
    5656
     
    107107         */
    108108        public function test_bp_xprofile_get_field_visibility_level_user_set() {
    109                 $u = $this->create_user();
     109                $u = $this->factory->user->create();
    110110                $g = $this->factory->xprofile_group->create();
    111111                $f = $this->factory->xprofile_field->create( array(
     
    126126         */
    127127        public function test_bp_xprofile_get_field_visibility_level_user_unset() {
    128                 $u = $this->create_user();
     128                $u = $this->factory->user->create();
    129129                $g = $this->factory->xprofile_group->create();
    130130                $f = $this->factory->xprofile_field->create( array(
     
    144144         */
    145145        public function test_bp_xprofile_get_field_visibility_level_admin_override() {
    146                 $u = $this->create_user();
     146                $u = $this->factory->user->create();
    147147                $g = $this->factory->xprofile_group->create();
    148148                $f = $this->factory->xprofile_field->create( array(
     
    538538         */
    539539        public function test_bp_get_member_profile_data_inside_loop() {
    540                 $u = $this->create_user();
     540                $u = $this->factory->user->create();
    541541                $g = $this->factory->xprofile_group->create();
    542542                $f = $this->factory->xprofile_field->create( array(
     
    563563         */
    564564        public function test_bp_get_member_profile_data_outside_of_loop() {
    565                 $u = $this->create_user();
     565                $u = $this->factory->user->create();
    566566                $g = $this->factory->xprofile_group->create();
    567567                $f = $this->factory->xprofile_field->create( array(
     
    584584         */
    585585        public function test_get_field_data_integer_zero() {
    586                 $u = $this->create_user();
     586                $u = $this->factory->user->create();
    587587                $g = $this->factory->xprofile_group->create();
    588588                $f = $this->factory->xprofile_field->create( array(
Note: See TracChangeset for help on using the changeset viewer.