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

    r8958 r9139  
    2020         */
    2121        public function test_get_users_with_exclude_querystring() {
    22                 $u1 = $this->create_user();
    23                 $u2 = $this->create_user();
    24                 $u3 = $this->create_user();
     22                $u1 = $this->factory->user->create();
     23                $u2 = $this->factory->user->create();
     24                $u3 = $this->factory->user->create();
    2525
    2626                $exclude_qs = $u1 . ',junkstring,' . $u3;
     
    3636         */
    3737        public function test_get_users_with_exclude_array() {
    38                 $u1 = $this->create_user();
    39                 $u2 = $this->create_user();
    40                 $u3 = $this->create_user();
     38                $u1 = $this->factory->user->create();
     39                $u2 = $this->factory->user->create();
     40                $u3 = $this->factory->user->create();
    4141
    4242                $exclude_array = array(
     
    5656         */
    5757        public function test_get_users_with_include_querystring() {
    58                 $u1 = $this->create_user( array(
     58                $u1 = $this->factory->user->create( array(
    5959                        'last_activity' => gmdate( 'Y-m-d H:i:s' ),
    6060                ) );
    61                 $u2 = $this->create_user( array(
     61                $u2 = $this->factory->user->create( array(
    6262                        'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
    6363                ) );
    64                 $u3 = $this->create_user( array(
     64                $u3 = $this->factory->user->create( array(
    6565                        'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 50 ),
    6666                ) );
     
    7878         */
    7979        public function test_get_users_with_include_array() {
    80                 $u1 = $this->create_user( array(
     80                $u1 = $this->factory->user->create( array(
    8181                        'last_activity' => gmdate( 'Y-m-d H:i:s' ),
    8282                ) );
    83                 $u2 = $this->create_user( array(
     83                $u2 = $this->factory->user->create( array(
    8484                        'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
    8585                ) );
    86                 $u3 = $this->create_user( array(
     86                $u3 = $this->factory->user->create( array(
    8787                        'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 50 ),
    8888                ) );
     
    110110         */
    111111        public function test_type_alphabetical() {
    112                 $u1 = $this->create_user( array(
     112                $u1 = $this->factory->user->create( array(
    113113                        'display_name' => 'foo',
    114114                ) );
    115                 $u2 = $this->create_user( array(
     115                $u2 = $this->factory->user->create( array(
    116116                        'display_name' => 'bar',
    117117                ) );
     
    129129         */
    130130        public function test_get_users_by_letter() {
    131                 $u1 = $this->create_user( array(
     131                $u1 = $this->factory->user->create( array(
    132132                        'display_name' => 'foo',
    133133                ) );
    134                 $u2 = $this->create_user( array(
     134                $u2 = $this->factory->user->create( array(
    135135                        'display_name' => 'bar',
    136136                ) );
     
    146146         */
    147147        public function test_search_users() {
    148                 $u1 = $this->create_user( array(
     148                $u1 = $this->factory->user->create( array(
    149149                        'display_name' => 'foo',
    150150                ) );
    151                 $u2 = $this->create_user( array(
     151                $u2 = $this->factory->user->create( array(
    152152                        'display_name' => 'bar',
    153153                ) );
     
    160160
    161161        public function test_get_specific_users() {
    162                 $u1 = $this->create_user();
    163                 $u2 = $this->create_user();
    164                 $u3 = $this->create_user();
     162                $u1 = $this->factory->user->create();
     163                $u2 = $this->factory->user->create();
     164                $u3 = $this->factory->user->create();
    165165
    166166                $include_array = array(
     
    180180         */
    181181        public function test_get_last_activity() {
    182                 $u = $this->create_user();
     182                $u = $this->factory->user->create();
    183183                $time = bp_core_current_time();
    184184
     
    196196         */
    197197        public function test_get_last_activity_store_in_cache() {
    198                 $u = $this->create_user();
     198                $u = $this->factory->user->create();
    199199                $time = bp_core_current_time();
    200200
     
    214214         */
    215215        public function test_get_last_activity_store_in_cache_multiple_users() {
    216                 $u1 = $this->create_user();
    217                 $u2 = $this->create_user();
     216                $u1 = $this->factory->user->create();
     217                $u2 = $this->factory->user->create();
    218218                $time = bp_core_current_time();
    219219
     
    235235         */
    236236        public function test_get_last_activity_from_cache_single_user() {
    237                 $u    = $this->create_user();
     237                $u    = $this->factory->user->create();
    238238                $time = bp_core_current_time();
    239239
     
    258258         */
    259259        public function test_get_last_activity_in_cache_multiple_users() {
    260                 $u1 = $this->create_user();
    261                 $u2 = $this->create_user();
     260                $u1 = $this->factory->user->create();
     261                $u2 = $this->factory->user->create();
    262262                $time = bp_core_current_time();
    263263
     
    283283         */
    284284        public function test_update_last_activity() {
    285                 $u = $this->create_user();
     285                $u = $this->factory->user->create();
    286286                $time = bp_core_current_time();
    287287                $time2 = '1968-12-25 01:23:45';
     
    302302         */
    303303        public function test_delete_last_activity() {
    304                 $u = $this->create_user();
     304                $u = $this->factory->user->create();
    305305                $time = bp_core_current_time();
    306306
Note: See TracChangeset for help on using the changeset viewer.