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

    r8958 r9139  
    66class BP_Tests_Notifications_Functions extends BP_UnitTestCase {
    77    public function test_cache_invalidation_all_for_user_on_save() {
    8         $u = $this->create_user();
     8        $u = $this->factory->user->create();
    99        $n1 = $this->factory->notification->create( array(
    1010            'component_name' => 'groups',
     
    3434
    3535    public function test_cache_invalidation_all_for_user_on_delete() {
    36         $u = $this->create_user();
     36        $u = $this->factory->user->create();
    3737        $n1 = $this->factory->notification->create( array(
    3838            'component_name' => 'groups',
     
    9797     */
    9898    public function test_bp_notifications_get_unread_notification_count_cache() {
    99         $u1 = $this->create_user();
    100         $u2 = $this->create_user();
     99        $u1 = $this->factory->user->create();
     100        $u2 = $this->factory->user->create();
    101101
    102102        $n1 = $this->factory->notification->create( array(
     
    126126     */
    127127    public function test_bp_has_notifications_filtering() {
    128         $u1 = $this->create_user();
    129         $u2 = $this->create_user();
     128        $u1 = $this->factory->user->create();
     129        $u2 = $this->factory->user->create();
    130130
    131131        // create a mixture of different notifications
Note: See TracChangeset for help on using the changeset viewer.