Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/22/2015 09:36:23 AM (11 years ago)
Author:
netweb
Message:

Tests: Adds forum, topic and reply insert function tests:

  • test_bbp_insert_forum() for bbp_insert_forum()
  • test_bbp_insert_topic() for bbp_insert_topic()
  • test_bbp_insert_reply() for bbp_insert_reply()

Props netweb. Fixes #2805

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/topics/functions/topic.php

    r5778 r5779  
    1111
    1212        /**
     13         * @group canonical
    1314         * @covers ::bbp_insert_topic
    14          * @todo   Implement test_bbp_insert_topic().
    1515         */
    1616        public function test_bbp_insert_topic() {
    17                 // Remove the following lines when you implement this test.
    18                 $this->markTestIncomplete(
    19                         'This test has not been implemented yet.'
    20                 );
     17
     18                $f = $this->factory->forum->create();
     19
     20                $t = $this->factory->topic->create( array(
     21                        'post_parent' => $f,
     22                        'topic_meta' => array(
     23                                'forum_id' => $f,
     24                        ),
     25                ) );
     26
     27                $r = $this->factory->reply->create( array(
     28                        'post_parent' => $t,
     29                        'reply_meta' => array(
     30                                'forum_id' => $f,
     31                                'topic_id' => $t,
     32                        ),
     33                ) );
     34
     35                // Topic post
     36                $this->assertSame( 'Topic 1', bbp_get_topic_title( $t ) );
     37                $this->assertSame( 'publish', bbp_get_topic_status( $t ) );
     38                $this->assertSame( $f, wp_get_post_parent_id( $t ) ); // post parent
     39
     40                // Topic meta
     41                $this->assertSame( $f, bbp_get_topic_forum_id( $t ) ); // _bbp_forum_id
     42                $this->assertSame( 1, bbp_get_topic_reply_count( $t, true ) );
     43                $this->assertSame( 0, bbp_get_topic_reply_count_hidden( $t, true ) );
     44                $this->assertSame( 1, bbp_get_topic_voice_count( $t, true ) );
     45                $this->assertSame( $r, bbp_get_topic_last_reply_id( $t ) );
     46                $this->assertSame( $r, bbp_get_topic_last_active_id( $t ) );
     47                $this->assertSame( 'right now', bbp_get_topic_last_active_time( $t ) );
    2148        }
    2249
Note: See TracChangeset for help on using the changeset viewer.