Skip to:
Content

bbPress.org

Changeset 5741


Ignore:
Timestamp:
05/13/2015 03:44:00 AM (9 years ago)
Author:
netweb
Message:

Tests: Improved performance of user component count function tests, now 33⅓% faster
Props thebrandonallen. See #2081

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/users/functions/counts.php

    r5708 r5741  
    1515    function test_bbp_update_user_topic_count() {
    1616        $u = $this->factory->user->create();
    17         $int_value = 9;
     17        $int_value = 3;
    1818
    1919        bbp_update_user_topic_count( $u, $int_value );
     
    2828    function test_bbp_update_user_reply_count() {
    2929        $u = $this->factory->user->create();
    30         $int_value = 9;
     30        $int_value = 3;
    3131
    3232        bbp_update_user_reply_count( $u, $int_value );
     
    4242    function test_bbp_get_user_topic_count() {
    4343        $u = $this->factory->user->create();
    44         $int_value = 9;
     44        $int_value = 3;
    4545        $formatted_value = bbp_number_format( $int_value );
    4646
     
    6363    function test_bbp_get_user_reply_count() {
    6464        $u = $this->factory->user->create();
    65         $int_value = 9;
     65        $int_value = 3;
    6666        $formatted_value = bbp_number_format( $int_value );
    6767
     
    8484    function test_bbp_get_user_post_count() {
    8585        $u = $this->factory->user->create();
    86         $int_value = 9;
     86        $int_value = 3;
    8787        $integer = true;
    8888
     
    117117        $this->assertFalse( $has_topics );
    118118
    119         $t = $this->factory->topic->create_many( 15, array(
     119        $t = $this->factory->topic->create_many( 3, array(
    120120            'post_author' => $u,
    121121        ) );
     
    138138        $this->assertFalse( $has_replies );
    139139
    140         $r = $this->factory->reply->create_many( 15, array(
     140        $r = $this->factory->reply->create_many( 3, array(
    141141            'post_author' => $u,
    142142        ) );
     
    154154     */
    155155    public function test_bbp_get_total_users() {
    156         $this->factory->user->create_many( 15 );
     156        $this->factory->user->create_many( 3 );
    157157
    158158        $users = (int) bbp_get_total_users();
    159159
    160160        // 15 + 1, the + 1 is the default admin user
    161         $this->assertSame( 16, $users );
     161        $this->assertSame( 4, $users );
    162162    }
    163163
     
    168168        $u = $this->factory->user->create();
    169169
    170         $t = $this->factory->topic->create_many( 15, array(
     170        $t = $this->factory->topic->create_many( 3, array(
    171171            'post_author' => $u,
    172172        ) );
    173173
    174174        $count = bbp_get_user_topic_count_raw( $u );
    175         $this->assertSame( 15, $count );
    176 
    177         $t = $this->factory->topic->create_many( 15, array(
     175        $this->assertSame( 3, $count );
     176
     177        $t = $this->factory->topic->create_many( 3, array(
    178178            'post_author' => $u,
    179179        ) );
    180180
    181181        $count = bbp_get_user_topic_count_raw( $u );
    182         $this->assertSame( 30, $count );
     182        $this->assertSame( 6, $count );
    183183    }
    184184
     
    189189        $u = $this->factory->user->create();
    190190
    191         $r = $this->factory->reply->create_many( 15, array(
     191        $r = $this->factory->reply->create_many( 3, array(
    192192            'post_author' => $u,
    193193        ) );
    194194
    195195        $count = bbp_get_user_reply_count_raw( $u );
    196         $this->assertSame( 15, $count );
    197 
    198         $r = $this->factory->reply->create_many( 15, array(
     196        $this->assertSame( 3, $count );
     197
     198        $r = $this->factory->reply->create_many( 3, array(
    199199            'post_author' => $u,
    200200        ) );
    201201
    202202        $count = bbp_get_user_reply_count_raw( $u );
    203         $this->assertSame( 30, $count );
     203        $this->assertSame( 6, $count );
    204204    }
    205205
     
    209209    public function test_bbp_bump_user_topic_count() {
    210210        $u = $this->factory->user->create();
    211         $int_value = 9;
     211        $int_value = 3;
    212212        $integer = true;
    213213
     
    228228    public function test_bbp_bump_user_reply_count() {
    229229        $u = $this->factory->user->create();
    230         $int_value = 9;
     230        $int_value = 3;
    231231        $integer = true;
    232232
     
    247247    public function test_bbp_increase_user_topic_count() {
    248248        $u = $this->factory->user->create();
    249         $int_value = 9;
     249        $int_value = 3;
    250250        $integer = true;
    251251
     
    270270    public function test_bbp_increase_user_reply_count() {
    271271        $u = $this->factory->user->create();
    272         $int_value = 9;
     272        $int_value = 3;
    273273        $integer = true;
    274274
     
    295295    public function test_bbp_decrease_user_topic_count() {
    296296        $u = $this->factory->user->create();
    297         $int_value = 9;
     297        $int_value = 3;
    298298        $integer = true;
    299299
     
    326326        $u = $this->factory->user->create();
    327327
    328         bbp_bump_user_reply_count( $u, 15 );
     328        bbp_bump_user_reply_count( $u, 3 );
    329329
    330330        $count = bbp_get_user_reply_count( $u, true );
    331         $this->assertSame( 15, $count );
     331        $this->assertSame( 3, $count );
    332332
    333333        $r = $this->factory->reply->create( array(
     
    338338
    339339        $count = bbp_get_user_reply_count( $u );
    340         $this->assertSame( '14', $count );
     340        $this->assertSame( '2', $count );
    341341
    342342        bbp_decrease_user_reply_count( $r );
    343343
    344344        $count = bbp_get_user_reply_count( $u, true );
    345         $this->assertSame( 13, $count );
     345        $this->assertSame( 1, $count );
    346346    }
    347347}
Note: See TracChangeset for help on using the changeset viewer.