| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * Tests for the topic component functions. |
| | 5 | * |
| | 6 | * @group get_last_thing |
| | 7 | */ |
| | 8 | class BBP_Tests_2806 extends BBP_UnitTestCase { |
| | 9 | |
| | 10 | /** |
| | 11 | * @ticket 2806 |
| | 12 | */ |
| | 13 | public function test_bbp_get_forum_and_topic_last_topic_and_last_reply_id() { |
| | 14 | |
| | 15 | $f = $this->factory->forum->create(); |
| | 16 | |
| | 17 | // Get the forums last topic id _bbp_last_topic_id |
| | 18 | $this->assertSame( 0, bbp_get_forum_last_topic_id( $f ) ); |
| | 19 | |
| | 20 | $t = $this->factory->topic->create( array( |
| | 21 | 'post_parent' => $f, |
| | 22 | 'topic_meta' => array( |
| | 23 | 'forum_id' => $f, |
| | 24 | ) |
| | 25 | ) ); |
| | 26 | |
| | 27 | // Get the forums last topic id _bbp_last_topic_id |
| | 28 | $this->assertSame( $t, bbp_get_forum_last_topic_id( $f ) ); |
| | 29 | |
| | 30 | // Get the topics last reply id _bbp_last_reply_id |
| | 31 | $this->assertSame( 0, bbp_get_topic_last_reply_id( $t ) ); |
| | 32 | |
| | 33 | // Create another reply |
| | 34 | $r = $this->factory->reply->create( array( |
| | 35 | 'post_parent' => $t, |
| | 36 | 'reply_meta' => array( |
| | 37 | 'forum_id' => $f, |
| | 38 | 'topic_id' => $t, |
| | 39 | ) |
| | 40 | ) ); |
| | 41 | // Get the topics last reply id _bbp_last_reply_id |
| | 42 | $this->assertSame( $r, bbp_get_topic_last_reply_id( $t ) ); |
| | 43 | } |
| | 44 | } |