Skip to:
Content

bbPress.org

Changeset 5890


Ignore:
Timestamp:
08/07/2015 09:54:05 AM (4 years ago)
Author:
netweb
Message:

Tests: Update tests to always include a parent topic for replies

This changeset ensures replies always have a parent topic which in turn ensures each reply is created with an accurate menu_order position.

Fixes #2843

Location:
trunk/tests/phpunit/testcases
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/replies/template/authors.php

    r5723 r5890  
    2828    public function test_bbp_get_reply_author_id() {
    2929        $u = $this->factory->user->create();
     30        $t = $this->factory->topic->create();
    3031        $r = $this->factory->reply->create( array(
     32            'post_parent' => $t,
    3133            'post_author' => $u,
     34            'reply_meta' => array(
     35                'topic_id' => $t,
     36            ),
    3237        ) );
    3338
     
    4449            'display_name' => 'Barry B. Benson',
    4550        ) );
    46 
     51        $t = $this->factory->topic->create();
    4752        $r = $this->factory->reply->create( array(
     53            'post_parent' => $t,
    4854            'post_author' => $u,
     55            'reply_meta' => array(
     56                'topic_id' => $t,
     57            ),
    4958        ) );
    5059
  • trunk/tests/phpunit/testcases/replies/template/post_type.php

    r5746 r5890  
    1515     */
    1616    public function test_bbp_reply_post_type() {
    17         $r = $this->factory->reply->create();
     17        $t = $this->factory->topic->create();
     18
     19        $r = $this->factory->reply->create( array(
     20            'post_parent' => $t,
     21            'reply_meta' => array(
     22                'topic_id' => $t,
     23            ),
     24        ) );
    1825
    1926        $robj = get_post_type_object( 'reply' );
  • trunk/tests/phpunit/testcases/users/functions/counts.php

    r5741 r5890  
    135135        $u = $this->factory->user->create();
    136136
     137        $t = $this->factory->topic->create();
     138
    137139        $has_replies = bbp_get_user_replies_created( $u );
    138140        $this->assertFalse( $has_replies );
    139141
    140         $r = $this->factory->reply->create_many( 3, array(
    141             'post_author' => $u,
    142         ) );
    143 
    144         bbp_update_reply( array(
    145             'reply_id' => $r,
     142        $r = $this->factory->reply->create( array(
     143            'post_parent' => $t,
     144            'post_author' => $u,
     145            'reply_meta' => array(
     146                'topic_id' => $t,
     147            ),
    146148        ) );
    147149
     
    189191        $u = $this->factory->user->create();
    190192
     193        $t = $this->factory->topic->create();
     194
    191195        $r = $this->factory->reply->create_many( 3, array(
    192             'post_author' => $u,
     196            'post_parent' => $t,
     197            'post_author' => $u,
     198            'reply_meta' => array(
     199                'topic_id' => $t,
     200            ),
    193201        ) );
    194202
     
    197205
    198206        $r = $this->factory->reply->create_many( 3, array(
    199             'post_author' => $u,
     207            'post_parent' => $t,
     208            'post_author' => $u,
     209            'reply_meta' => array(
     210                'topic_id' => $t,
     211            ),
    200212        ) );
    201213
     
    282294        $r = $this->factory->reply->create_many( $int_value, array(
    283295            'post_parent' => $t,
     296            'post_author' => $u,
     297            'reply_meta' => array(
     298                'topic_id' => $t,
     299            ),
    284300        ) );
    285301
     
    298314        $integer = true;
    299315
    300         bbp_bump_user_topic_count( $u, $int_value );
     316        bbp_update_user_topic_count( $u, $int_value );
    301317
    302318        $count = bbp_get_user_topic_count( $u, $integer );
     
    325341    public function test_bbp_decrease_user_reply_count() {
    326342        $u = $this->factory->user->create();
    327 
    328         bbp_bump_user_reply_count( $u, 3 );
    329 
    330         $count = bbp_get_user_reply_count( $u, true );
    331         $this->assertSame( 3, $count );
     343        $int_value = 3;
     344        $integer = true;
     345
     346        bbp_update_user_reply_count( $u, $int_value );
     347
     348        $count = bbp_get_user_reply_count( $u, $integer );
     349        $this->assertSame( $int_value, $count );
     350
     351        $t = $this->factory->topic->create();
    332352
    333353        $r = $this->factory->reply->create( array(
    334             'post_author' => $u,
    335         ) );
    336 
     354            'post_parent' => $t,
     355            'post_author' => $u,
     356            'reply_meta' => array(
     357                'topic_id' => $t,
     358            ),
     359        ) );
     360
     361        // Minus 1
    337362        bbp_decrease_user_reply_count( $r );
    338363
    339         $count = bbp_get_user_reply_count( $u );
    340         $this->assertSame( '2', $count );
    341 
     364        $count = bbp_get_user_reply_count( $u, $integer );
     365        $this->assertSame( $int_value - 1, $count );
     366
     367        // Minus 2
    342368        bbp_decrease_user_reply_count( $r );
    343369
    344         $count = bbp_get_user_reply_count( $u, true );
    345         $this->assertSame( 1, $count );
     370        $count = bbp_get_user_reply_count( $u, $integer );
     371        $this->assertSame( $int_value - 2, $count );
    346372    }
    347373}
Note: See TracChangeset for help on using the changeset viewer.