Skip to:
Content

bbPress.org

Changeset 5871


Ignore:
Timestamp:
07/20/2015 11:44:52 AM (6 years ago)
Author:
netweb
Message:

Tests: Add forum last active id test test_bbp_get_forum_last_active_id_with_pending_reply().

This test tests the forums last active id to ensure replies with post status pending are not used as the forums last active id until the reply is approved.

See #meta1140

File:
1 edited

Legend:

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

    r5863 r5871  
    5252
    5353    /**
     54     * @covers ::bbp_forum_last_active_id
     55     * @covers ::bbp_get_forum_last_active_id
     56     */
     57    public function test_bbp_get_forum_last_active_id_with_pending_reply() {
     58        $u = $this->factory->user->create_many( 2 );
     59        $f = $this->factory->forum->create();
     60
     61        $last_id = bbp_get_forum_last_active_id( $f );
     62        $this->assertSame( 0, $last_id );
     63
     64        bbp_update_forum_last_active_id( $f );
     65
     66        $last_id = bbp_get_forum_last_active_id( $f );
     67        $this->assertSame( 0, $last_id );
     68
     69        $t = $this->factory->topic->create( array(
     70            'post_parent' => $f,
     71            'topic_meta' => array(
     72                'forum_id' => $f,
     73            ),
     74        ) );
     75
     76        bbp_update_forum_last_active_id( $f );
     77
     78        $last_id = bbp_get_forum_last_active_id( $f );
     79        $this->assertSame( $t, $last_id );
     80
     81        $r1 = $this->factory->reply->create( array(
     82            'post_parent' => $t,
     83            'reply_meta' => array(
     84                'forum_id' => $f,
     85                'topic_id' => $t,
     86            ),
     87        ) );
     88
     89        bbp_update_forum_last_active_id( $f );
     90
     91        $last_id = bbp_get_forum_last_active_id( $f );
     92        $this->assertSame( $r1, $last_id );
     93
     94        $r2 = $this->factory->reply->create( array(
     95            'post_parent' => $t,
     96            'post_author' => $u[1],
     97            'post_status' => bbp_get_pending_status_id(),
     98            'reply_meta' => array(
     99                'forum_id' => $f,
     100                'topic_id' => $t,
     101            )
     102        ) );
     103
     104        $last_id = bbp_get_forum_last_active_id( $f );
     105        $this->assertSame( $r1, $last_id );
     106
     107        bbp_approve_reply( $r2 );
     108
     109        $last_id = bbp_get_forum_last_active_id( $f );
     110        $this->assertSame( $r2, $last_id );
     111    }
     112
     113    /**
    54114     * @covers ::bbp_forum_last_active_time
    55115     * @covers ::bbp_get_forum_last_active_time
Note: See TracChangeset for help on using the changeset viewer.