Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/27/2015 03:00:42 AM (10 years ago)
Author:
boonebgorges
Message:

Don't create a current user by default in most unit tests.

The default state of our tests should be as a logged-out user. BP does pretty
different things with different kinds of logged-in users, so individual tests
should decide for themselves what the current user status should be.

Moreover, the creation of fixture users is fairly resource-intensive. Not
creating users when they're not needed makes the test suite run 5-10% faster.

See #6009.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r9533 r9561  
    66 */
    77class BP_Tests_BP_User_Query_TestCases extends BP_UnitTestCase {
    8     protected $old_current_user = 0;
    9 
    10     public function setUp() {
    11         parent::setUp();
    12 
    13         $this->old_current_user = get_current_user_id();
    14         $this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
    15     }
    16 
    17     public function tearDown() {
    18         parent::tearDown();
    19         $this->set_current_user( $this->old_current_user );
    20     }
    21 
    228    /**
    239     * Checks that user_id returns friends
Note: See TracChangeset for help on using the changeset viewer.