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/xprofile/class-bp-xprofile-profiledata.php

    r8958 r9139  
    1010     */
    1111    public function test_exists_when_doesnt_exist() {
    12         $u = $this->create_user();
     12        $u = $this->factory->user->create();
    1313        $g = $this->factory->xprofile_group->create();
    1414        $f = $this->factory->xprofile_field->create( array(
     
    2626     */
    2727    public function test_exists_when_exists_uncached() {
    28         $u = $this->create_user();
     28        $u = $this->factory->user->create();
    2929        $g = $this->factory->xprofile_group->create();
    3030        $f = $this->factory->xprofile_field->create( array(
     
    4646     */
    4747    public function test_exists_when_exists_in_cache() {
    48         $u = $this->create_user();
     48        $u = $this->factory->user->create();
    4949        $g = $this->factory->xprofile_group->create();
    5050        $f = $this->factory->xprofile_field->create( array(
     
    6666     */
    6767    public function test_get_fielddataid_byid_when_doesnt_exist() {
    68         $u = $this->create_user();
     68        $u = $this->factory->user->create();
    6969        $g = $this->factory->xprofile_group->create();
    7070        $f = $this->factory->xprofile_field->create( array(
     
    8383     */
    8484    public function test_get_fielddataid_byid_when_exists_uncached() {
    85         $u = $this->create_user();
     85        $u = $this->factory->user->create();
    8686        $g = $this->factory->xprofile_group->create();
    8787        $f = $this->factory->xprofile_field->create( array(
     
    106106     */
    107107    public function test_get_fielddataid_byid_when_exists_in_cache() {
    108         $u = $this->create_user();
     108        $u = $this->factory->user->create();
    109109        $g = $this->factory->xprofile_group->create();
    110110        $f = $this->factory->xprofile_field->create( array(
     
    125125     */
    126126    public function test_get_value_byid_singleuser_uncached() {
    127         $u = $this->create_user();
     127        $u = $this->factory->user->create();
    128128        $g = $this->factory->xprofile_group->create();
    129129        $f = $this->factory->xprofile_field->create( array(
     
    150150        $time = date( 'Y-m-d H:i:s', time() - 60*60*24 );
    151151
    152         $u1 = $this->create_user();
    153         $u2 = $this->create_user();
     152        $u1 = $this->factory->user->create();
     153        $u2 = $this->factory->user->create();
    154154        $g = $this->factory->xprofile_group->create();
    155155        $f = $this->factory->xprofile_field->create( array(
     
    206206     */
    207207    public function test_get_value_byid_singleuser_cached() {
    208         $u = $this->create_user();
     208        $u = $this->factory->user->create();
    209209        $g = $this->factory->xprofile_group->create();
    210210        $f = $this->factory->xprofile_field->create( array(
     
    230230        $time = date( 'Y-m-d H:i:s', time() - 60*60*24 );
    231231
    232         $u1 = $this->create_user();
    233         $u2 = $this->create_user();
     232        $u1 = $this->factory->user->create();
     233        $u2 = $this->factory->user->create();
    234234        $g = $this->factory->xprofile_group->create();
    235235        $f = $this->factory->xprofile_field->create( array(
     
    279279     */
    280280    public function test_get_all_for_user_uncached() {
    281         $u = $this->create_user();
     281        $u = $this->factory->user->create();
    282282        $g1 = $this->factory->xprofile_group->create();
    283283        $g2 = $this->factory->xprofile_group->create();
     
    358358     */
    359359    public function test_get_all_for_user_cached() {
    360         $u = $this->create_user();
     360        $u = $this->factory->user->create();
    361361        $g1 = $this->factory->xprofile_group->create();
    362362        $g2 = $this->factory->xprofile_group->create();
Note: See TracChangeset for help on using the changeset viewer.