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

    r9052 r9139  
    453453        add_filter( 'bp_is_username_compatibility_mode', '__return_false' );
    454454
    455         $u = $this->create_user( array(
     455        $u = $this->factory->user->create( array(
    456456            'user_login' => 'foo bar baz',
    457457            'user_nicename' => 'foo-bar-baz',
     
    469469        add_filter( 'bp_is_username_compatibility_mode', '__return_true' );
    470470
    471         $u1 = $this->create_user( array(
     471        $u1 = $this->factory->user->create( array(
    472472            'user_login' => 'foo bar baz',
    473473            'user_nicename' => 'foo-bar-baz',
    474474        ) );
    475475
    476         $u2 = $this->create_user( array(
     476        $u2 = $this->factory->user->create( array(
    477477            'user_login' => 'foo.bar.baz',
    478478            'user_nicename' => 'foo-bar-baz',
     
    491491        add_filter( 'bp_is_username_compatibility_mode', '__return_false' );
    492492
    493         $u = $this->create_user( array(
     493        $u = $this->factory->user->create( array(
    494494            'user_login' => 'foo bar baz',
    495495            'user_nicename' => 'foo-bar-baz',
     
    508508
    509509        // all spaces are hyphens
    510         $u1 = $this->create_user( array(
     510        $u1 = $this->factory->user->create( array(
    511511            'user_login' => 'foo bar baz',
    512512            'user_nicename' => 'foobarbaz',
     
    514514
    515515        // no spaces are hyphens
    516         $u2 = $this->create_user( array(
     516        $u2 = $this->factory->user->create( array(
    517517            'user_login' => 'foo-bar-baz-1',
    518518            'user_nicename' => 'foobarbaz-1',
     
    520520
    521521        // some spaces are hyphens
    522         $u3 = $this->create_user( array(
     522        $u3 = $this->factory->user->create( array(
    523523            'user_login' => 'foo bar-baz 2',
    524524            'user_nicename' => 'foobarbaz-2',
    525525        ) );
    526526
    527         $u4 = $this->create_user( array(
     527        $u4 = $this->factory->user->create( array(
    528528            'user_login' => 'foo.bar.baz',
    529529            'user_nicename' => 'foo-bar-baz',
     
    543543     */
    544544    public function test_bp_activity_format_activity_action_activity_update() {
    545         $u = $this->create_user();
     545        $u = $this->factory->user->create();
    546546        $a = $this->factory->activity->create( array(
    547547            'component' => buddypress()->activity->id,
     
    562562     */
    563563    public function test_bp_activity_format_activity_action_activity_comment() {
    564         $u = $this->create_user();
     564        $u = $this->factory->user->create();
    565565        $a = $this->factory->activity->create( array(
    566566            'component' => buddypress()->activity->id,
     
    747747     */
    748748    public function test_add_user_favorite_already_favorited() {
    749         $u = $this->create_user();
     749        $u = $this->factory->user->create();
    750750        $a = $this->factory->activity->create();
    751751
     
    762762     */
    763763    public function test_add_user_favorite_not_yet_favorited() {
    764         $u = $this->create_user();
     764        $u = $this->factory->user->create();
    765765        $a = $this->factory->activity->create();
    766766        $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) );
     
    772772     */
    773773    public function test_remove_user_favorite_bad_activity_id() {
    774         $u1 = $this->create_user();
    775         $u2 = $this->create_user();
     774        $u1 = $this->factory->user->create();
     775        $u2 = $this->factory->user->create();
    776776        $a = $this->factory->activity->create();
    777777
     
    805805     */
    806806    public function test_bp_activity_post_update_success() {
    807         $u = $this->create_user();
     807        $u = $this->factory->user->create();
    808808
    809809        $a = bp_activity_post_update( array(
Note: See TracChangeset for help on using the changeset viewer.