Skip to:
Content

bbPress.org

Changeset 5792


Ignore:
Timestamp:
05/23/2015 08:35:11 AM (9 years ago)
Author:
netweb
Message:

Tests: Updated forum component count functions tests

Props thebrandonallen, netweb. See #2801

File:
1 edited

Legend:

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

    r5777 r5792  
    6161        $f1 = $this->factory->forum->create();
    6262
    63         $f2 = $this->factory->forum->create_many( 9, array(
    64             'post_parent' => $f1,
    65         ) );
    66 
    67         $count = bbp_get_forum_subforum_count( $f1, $integer = true );
    68         $this->assertSame( 0, $count );
    69 
    70         $count = count( bbp_forum_query_subforum_ids( $f1 ) );
    71         $this->assertSame( 9, $count );
     63        $f2 = $this->factory->forum->create_many( 3, array(
     64            'post_parent' => $f1,
     65        ) );
     66
     67        $count = bbp_get_forum_subforum_count( $f1, true );
     68        $this->assertSame( 0, $count );
    7269
    7370        bbp_update_forum_subforum_count( $f1 );
    7471
    75         $count = bbp_get_forum_subforum_count( $f1, $integer = true );
    76         $this->assertSame( 9, $count );
    77 
    78         $count = count( bbp_forum_query_subforum_ids( $f1 ) );
    79         $this->assertSame( 9, $count );
     72        $count = bbp_get_forum_subforum_count( $f1, true );
     73        $this->assertSame( 3, $count );
    8074    }
    8175
     
    168162        $f = $this->factory->forum->create();
    169163
    170         $count = bbp_get_forum_topic_count( $f );
    171         $this->assertSame( '0', $count );
    172 
    173         $t = $this->factory->topic->create_many( 15, array(
     164        $count = bbp_get_forum_topic_count( $f, false, true );
     165        $this->assertSame( 0, $count );
     166
     167        $t = $this->factory->topic->create_many( 3, array(
    174168            'post_parent' => $f,
     169            'topic_meta' => array(
     170                'forum_id' => $f,
     171            ),
    175172        ) );
    176173
    177174        bbp_update_forum_topic_count_hidden( $f );
    178175
    179         $count = bbp_get_forum_topic_count_hidden( $f );
    180         $this->assertSame( '0', $count );;
    181 
    182         bbp_spam_topic( $t[11] );
     176        $count = bbp_get_forum_topic_count_hidden( $f, true );
     177        $this->assertSame( 0, $count );;
     178
     179        bbp_spam_topic( $t[2] );
    183180
    184181        bbp_update_forum_topic_count_hidden( $f );
    185182
    186         $count = bbp_get_forum_topic_count_hidden( $f );
    187         $this->assertSame( '1', $count );;
    188 
    189         bbp_unapprove_topic( $t[7] );
     183        $count = bbp_get_forum_topic_count_hidden( $f, true );
     184        $this->assertSame( 1, $count );;
     185
     186        bbp_unapprove_topic( $t[0] );
    190187
    191188        bbp_update_forum_topic_count_hidden( $f );
    192189
    193         $count = bbp_get_forum_topic_count_hidden( $f );
    194         $this->assertSame( '2', $count );
     190        $count = bbp_get_forum_topic_count_hidden( $f, true );
     191        $this->assertSame( 2, $count );
    195192    }
    196193
     
    199196     */
    200197    public function test_bbp_update_forum_reply_count() {
    201         $f = $this->factory->forum->create();
    202 
    203         $count = bbp_get_forum_reply_count( $f );
    204         $this->assertSame( '0', $count );
    205 
    206         $t = $this->factory->topic->create( array(
    207             'post_parent' => $f,
    208         ) );
    209 
    210         bbp_update_forum_reply_count( $f );
    211 
    212         $count = bbp_get_forum_reply_count( $f );
    213         $this->assertSame( '0', $count );
    214 
    215         $r = $this->factory->reply->create_many( 15, array(
    216             'post_parent' => $t,
    217         ) );
    218 
    219         bbp_update_forum_reply_count( $f );
    220 
    221         $count = bbp_get_forum_reply_count( $f );
    222         $this->assertSame( '15', $count );
     198        $f1 = $this->factory->forum->create();
     199
     200        $f2 = $this->factory->forum->create( array(
     201            'post_parent' => $f1,
     202        ) );
     203
     204        $t1 = $this->factory->topic->create( array(
     205            'post_parent' => $f1,
     206            'topic_meta' => array(
     207                'forum_id' => $f1,
     208            ),
     209        ) );
     210
     211        $t2 = $this->factory->topic->create( array(
     212            'post_parent' => $f2,
     213            'topic_meta' => array(
     214                'forum_id' => $f2,
     215            ),
     216        ) );
     217
     218        $count = bbp_get_forum_reply_count( $f1, false, true );
     219        $this->assertSame( 0, $count );
     220
     221        $count = bbp_update_forum_reply_count( $f1 );
     222        $this->assertSame( 0, $count );
     223
     224        $this->factory->reply->create_many( 3, array(
     225            'post_parent' => $t1,
     226            'reply_meta' => array(
     227                'forum_id' => $f1,
     228                'topic_id' => $t1,
     229            ),
     230        ) );
     231
     232        $count = bbp_update_forum_reply_count( $f1 );
     233        $this->assertSame( 3, $count );
     234
     235        $this->factory->reply->create_many( 3, array(
     236            'post_parent' => $t2,
     237            'reply_meta' => array(
     238                'forum_id' => $f2,
     239                'topic_id' => $t2,
     240            ),
     241        ) );
     242
     243        $count = bbp_update_forum_reply_count( $f1 );
     244        $this->assertSame( 6, $count );
     245
     246        $count = bbp_update_forum_reply_count( $f2 );
     247        $this->assertSame( 3, $count );
    223248    }
    224249}
Note: See TracChangeset for help on using the changeset viewer.