Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/19/2016 10:04:37 AM (8 years ago)
Author:
netweb
Message:

Tests: Improve test performance by reducing the number of topics and replies created in test_bbp_forum_trashed_untrashed_topic_counts() and test_bbp_forum_spammed_unspammed_topic_counts() tests

File:
1 edited

Legend:

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

    r5921 r6011  
    6868    public function test_bbp_forum_trashed_untrashed_topic_counts() {
    6969        $f = $this->factory->forum->create();
    70         $t = $this->factory->topic->create_many( 3, array(
    71             'post_parent' => $f,
    72             'topic_meta' => array(
    73                 'forum_id' => $f,
    74             ),
    75         ) );
    76         $r1 = $this->factory->reply->create_many( 2, array(
     70        $t = $this->factory->topic->create_many( 2, array(
     71            'post_parent' => $f,
     72            'topic_meta' => array(
     73                'forum_id' => $f,
     74            ),
     75        ) );
     76        $r1 = $this->factory->reply->create_many( 1, array(
     77            'post_parent' => $t[0],
     78            'reply_meta' => array(
     79                'forum_id' => $f,
     80                'topic_id' => $t[0],
     81            ),
     82        ) );
     83        $r2 = $this->factory->reply->create_many( 1, array(
    7784            'post_parent' => $t[1],
    7885            'reply_meta' => array(
     
    8188            ),
    8289        ) );
    83         $r2 = $this->factory->reply->create_many( 2, array(
    84             'post_parent' => $t[2],
    85             'reply_meta' => array(
    86                 'forum_id' => $f,
    87                 'topic_id' => $t[2],
    88             ),
    89         ) );
    9090
    9191        $count = bbp_update_forum_topic_count( $f );
    92         $this->assertSame( 3, $count );
     92        $this->assertSame( 2, $count );
    9393
    9494        $count = bbp_update_forum_topic_count_hidden( $f );
     
    9696
    9797        $count = bbp_update_forum_reply_count( $f );
    98         $this->assertSame( 4, $count );
     98        $this->assertSame( 2, $count );
    9999
    100100        // ToDo: Update this to use bbp_trash_topic().
    101         wp_trash_post( $t[2] );
    102 
    103         $count = bbp_get_forum_topic_count( $f, true, true );
    104         $this->assertSame( 2, $count );
    105 
    106         $count = bbp_get_forum_topic_count_hidden( $f, true, true );
    107         $this->assertSame( 1, $count );
    108 
    109         $count = bbp_get_forum_reply_count( $f, true, true );
    110         $this->assertSame( 2, $count );
     101        wp_trash_post( $t[1] );
     102
     103        $count = bbp_get_forum_topic_count( $f, true, true );
     104        $this->assertSame( 1, $count );
     105
     106        $count = bbp_get_forum_topic_count_hidden( $f, true, true );
     107        $this->assertSame( 1, $count );
     108
     109        $count = bbp_get_forum_reply_count( $f, true, true );
     110        $this->assertSame( 1, $count );
    111111
    112112        // ToDo: Update this to use bbp_untrash_topic().
    113         wp_untrash_post( $t[2] );
    114 
    115         $count = bbp_get_forum_topic_count( $f, true, true );
    116         $this->assertSame( 3, $count );
    117 
    118         $count = bbp_get_forum_topic_count_hidden( $f, true, true );
    119         $this->assertSame( 0, $count );
    120 
    121         $count = bbp_get_forum_reply_count( $f, true, true );
    122         $this->assertSame( 4, $count );
     113        wp_untrash_post( $t[1] );
     114
     115        $count = bbp_get_forum_topic_count( $f, true, true );
     116        $this->assertSame( 2, $count );
     117
     118        $count = bbp_get_forum_topic_count_hidden( $f, true, true );
     119        $this->assertSame( 0, $count );
     120
     121        $count = bbp_get_forum_reply_count( $f, true, true );
     122        $this->assertSame( 2, $count );
    123123    }
    124124
     
    128128    public function test_bbp_forum_spammed_unspammed_topic_counts() {
    129129        $f = $this->factory->forum->create();
    130         $t = $this->factory->topic->create_many( 3, array(
    131             'post_parent' => $f,
    132             'topic_meta' => array(
    133                 'forum_id' => $f,
    134             ),
    135         ) );
    136         $r1 = $this->factory->reply->create_many( 2, array(
     130        $t = $this->factory->topic->create_many( 2, array(
     131            'post_parent' => $f,
     132            'topic_meta' => array(
     133                'forum_id' => $f,
     134            ),
     135        ) );
     136        $r1 = $this->factory->reply->create_many( 1, array(
     137            'post_parent' => $t[0],
     138            'reply_meta' => array(
     139                'forum_id' => $f,
     140                'topic_id' => $t[0],
     141            ),
     142        ) );
     143        $r2 = $this->factory->reply->create_many( 1, array(
    137144            'post_parent' => $t[1],
    138145            'reply_meta' => array(
     
    141148            ),
    142149        ) );
    143         $r2 = $this->factory->reply->create_many( 2, array(
    144             'post_parent' => $t[2],
    145             'reply_meta' => array(
    146                 'forum_id' => $f,
    147                 'topic_id' => $t[2],
    148             ),
    149         ) );
    150150
    151151        $count = bbp_update_forum_topic_count( $f );
    152         $this->assertSame( 3, $count );
     152        $this->assertSame( 2, $count );
    153153
    154154        $count = bbp_update_forum_topic_count_hidden( $f );
     
    156156
    157157        $count = bbp_update_forum_reply_count( $f );
    158         $this->assertSame( 4, $count );
    159 
    160         bbp_spam_topic( $t[2] );
    161 
    162         $count = bbp_get_forum_topic_count( $f, true, true );
    163         $this->assertSame( 2, $count );
    164 
    165         $count = bbp_get_forum_topic_count_hidden( $f, true, true );
    166         $this->assertSame( 1, $count );
    167 
    168         $count = bbp_get_forum_reply_count( $f, true, true );
    169         $this->assertSame( 2, $count );
    170 
    171         bbp_unspam_topic( $t[2] );
    172 
    173         $count = bbp_get_forum_topic_count( $f, true, true );
    174         $this->assertSame( 3, $count );
    175 
    176         $count = bbp_get_forum_topic_count_hidden( $f, true, true );
    177         $this->assertSame( 0, $count );
    178 
    179         $count = bbp_get_forum_reply_count( $f, true, true );
    180         $this->assertSame( 4, $count );
     158        $this->assertSame( 2, $count );
     159
     160        bbp_spam_topic( $t[1] );
     161
     162        $count = bbp_get_forum_topic_count( $f, true, true );
     163        $this->assertSame( 1, $count );
     164
     165        $count = bbp_get_forum_topic_count_hidden( $f, true, true );
     166        $this->assertSame( 1, $count );
     167
     168        $count = bbp_get_forum_reply_count( $f, true, true );
     169        $this->assertSame( 1, $count );
     170
     171        bbp_unspam_topic( $t[1] );
     172
     173        $count = bbp_get_forum_topic_count( $f, true, true );
     174        $this->assertSame( 2, $count );
     175
     176        $count = bbp_get_forum_topic_count_hidden( $f, true, true );
     177        $this->assertSame( 0, $count );
     178
     179        $count = bbp_get_forum_reply_count( $f, true, true );
     180        $this->assertSame( 2, $count );
    181181    }
    182182
Note: See TracChangeset for help on using the changeset viewer.