Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/27/2015 03:00:42 AM (9 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/avatars.php

    r9455 r9561  
    55 */
    66class BP_Tests_Avatars extends BP_UnitTestCase {
    7     protected $old_current_user = 0;
    8 
    97    private $params = array();
    10 
    11     public function setUp() {
    12         parent::setUp();
    13 
    14         $this->old_current_user = get_current_user_id();
    15         $this->administrator    = $this->factory->user->create( array( 'role' => 'administrator' ) );
    16         wp_set_current_user( $this->administrator );
    17     }
    18 
    19     public function tearDown() {
    20         parent::tearDown();
    21         wp_set_current_user( $this->old_current_user );
    22     }
    238
    249    private function clean_existing_avatars( $type = 'user' ) {
     
    5944        }
    6045
     46        $u = $this->factory->user->create();
     47
    6148        // get BP root blog's upload directory data
    6249        $upload_dir = wp_upload_dir();
     
    6451        // create new subsite
    6552        $blog_id = $this->factory->blog->create( array(
    66             'user_id' => $this->administrator,
     53            'user_id' => $u,
    6754            'title'   => 'Test Title',
    6855            'path'    => '/path' . rand() . time() . '/',
Note: See TracChangeset for help on using the changeset viewer.