Skip to:
Content

bbPress.org

Changeset 5844


Ignore:
Timestamp:
07/15/2015 09:27:11 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Add unit test for last topic & reply ID's for topics & forums. Fixes #2806. Props netweb.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/forums/template/get-last-thing.php

    r5786 r5844  
    7474        $this->assertSame( $now, $last_time );
    7575
    76         $r = $this->factory->reply->create( array(
     76        $this->factory->reply->create( array(
    7777            'post_parent' => $t,
    7878            'reply_meta' => array(
     
    130130        ) );
    131131
    132         $r = $this->factory->reply->create( array(
     132        $this->factory->reply->create( array(
    133133            'post_parent' => $t,
    134134            'reply_meta' => array(
     
    172172        ) );
    173173
    174         $r = $this->factory->reply->create( array(
     174        $this->factory->reply->create( array(
    175175            'post_parent' => $t,
    176176            'post_author' => $u,
     
    204204        $f = $this->factory->forum->create();
    205205
    206         $forum = bbp_get_forum_last_reply_id( $f );
     206    //  $forum = bbp_get_forum_last_reply_id( $f );
    207207    //  $this->assertSame( 'bbp_get_forum_last_reply_id', $forum );
    208208    //  $f = $this->factory->forum->create();
     
    215215        ) );
    216216
    217         $r1 = $this->factory->reply->create( array(
     217        $this->factory->reply->create( array(
    218218            'post_parent' => $t,
    219219            'reply_meta' => array(
     
    229229        bbp_get_forum_last_reply_id( $f );
    230230
    231         $r2 = $this->factory->reply->create( array(
     231        $this->factory->reply->create( array(
    232232            'post_parent' => $t,
    233233            'reply_meta' => array(
     
    258258        ) );
    259259
    260         $r = $this->factory->reply->create( array(
     260        $this->factory->reply->create( array(
    261261            'post_parent' => $t,
    262262            'reply_meta' => array(
     
    340340        );
    341341    }
     342
     343    /**
     344     * @covers ::bbp_forum_last_topic_id
     345     * @covers ::bbp_get_forum_last_topic_id
     346     * @covers ::bbp_forum_last_reply_id
     347     * @covers ::bbp_get_forum_last_reply_id
     348     * @covers ::bbp_topic_last_reply_id
     349     * @covers ::bbp_get_topic_last_reply_id
     350     */
     351    public function test_bbp_get_forum_and_topic_last_topic_id_and_last_reply_id() {
     352
     353        $f = $this->factory->forum->create();
     354
     355        // Get the forums last topic id _bbp_last_topic_id
     356        $this->assertSame( 0, bbp_get_forum_last_topic_id( $f ) );
     357
     358        $t = $this->factory->topic->create( array(
     359            'post_parent' => $f,
     360            'topic_meta' => array(
     361                'forum_id' => $f,
     362            )
     363        ) );
     364
     365        // Get the forums last topic id _bbp_last_topic_id
     366        $this->assertSame( $t, bbp_get_forum_last_topic_id( $f ) );
     367
     368        // Get the topics last reply id _bbp_last_reply_id
     369        $this->assertSame( 0, bbp_get_topic_last_reply_id( $t ) );
     370
     371        // Create another reply
     372        $r = $this->factory->reply->create( array(
     373            'post_parent' => $t,
     374            'reply_meta' => array(
     375                'forum_id' => $f,
     376                'topic_id' => $t,
     377            )
     378        ) );
     379
     380        // Get the topics last reply id _bbp_last_reply_id
     381        $this->assertSame( $r, bbp_get_topic_last_reply_id( $t ) );
     382    }
    342383}
Note: See TracChangeset for help on using the changeset viewer.