Skip to:
Content

bbPress.org

Changeset 7780


Ignore:
Timestamp:
10/04/2026 07:36:22 AM (5 weeks ago)
Author:
johnjamesjacoby
Message:

Tests: Cover topic and reply template loops.

Replace twelve incomplete tests for topic and reply query loops and post-type settings. Verify populated and empty loops, current-post advancement, labels, rewrite settings, and supported features.

In trunk, for 2.7.

See #3695.

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

Legend:

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

    r5725 r7780  
    1212        /**
    1313         * @covers ::bbp_has_replies
    14          * @todo   Implement test_bbp_has_replies().
    1514         */
    1615        public function test_bbp_has_replies() {
    17                 // Remove the following lines when you implement this test.
    18                 $this->markTestIncomplete(
    19                         'This test has not been implemented yet.'
    20                 );
     16                $topic_id = $this->factory->topic->create();
     17                $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) );
     18
     19                $this->assertTrue( bbp_has_replies( array(
     20                        'post_type'   => bbp_get_reply_post_type(),
     21                        'post_parent' => $topic_id,
     22                ) ) );
     23                $this->assertSame( 1, bbpress()->reply_query->post_count );
     24                $this->assertSame( $reply_id, bbpress()->reply_query->posts[0]->ID );
     25                $this->assertFalse( bbp_has_replies( array(
     26                        'post_type'   => bbp_get_reply_post_type(),
     27                        'post_parent' => $reply_id,
     28                ) ) );
    2129        }
    2230
    2331        /**
    2432         * @covers ::bbp_replies
    25          * @todo   Implement test_bbp_replies().
    2633         */
    2734        public function test_bbp_replies() {
    28                 // Remove the following lines when you implement this test.
    29                 $this->markTestIncomplete(
    30                         'This test has not been implemented yet.'
    31                 );
     35                $topic_id = $this->factory->topic->create();
     36                $this->factory->reply->create( array( 'post_parent' => $topic_id ) );
     37                bbp_has_replies( array(
     38                        'post_type'   => bbp_get_reply_post_type(),
     39                        'post_parent' => $topic_id,
     40                ) );
     41
     42                $this->assertTrue( bbp_replies() );
     43                bbp_the_reply();
     44                $this->assertFalse( bbp_replies() );
    3245        }
    3346
    3447        /**
    3548         * @covers ::bbp_the_reply
    36          * @todo   Implement test_bbp_the_reply().
    3749         */
    3850        public function test_bbp_the_reply() {
    39                 // Remove the following lines when you implement this test.
    40                 $this->markTestIncomplete(
    41                         'This test has not been implemented yet.'
    42                 );
     51                $topic_id = $this->factory->topic->create();
     52                $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) );
     53                bbp_has_replies( array(
     54                        'post_type'   => bbp_get_reply_post_type(),
     55                        'post_parent' => $topic_id,
     56                ) );
     57
     58                $this->assertTrue( bbp_replies() );
     59                bbp_the_reply();
     60                $this->assertSame( $reply_id, get_the_ID() );
     61                $this->assertFalse( bbp_replies() );
    4362        }
    4463}
  • trunk/tests/phpunit/testcases/replies/template/post_type.php

    r6071 r7780  
    4646        /**
    4747         * @covers ::bbp_get_reply_post_type_labels
    48          * @todo   Implement test_bbp_get_reply_post_type_labels().
    4948         */
    5049        public function test_bbp_get_reply_post_type_labels() {
    51                 // Remove the following lines when you implement this test.
    52                 $this->markTestIncomplete(
    53                         'This test has not been implemented yet.'
    54                 );
     50                $labels = bbp_get_reply_post_type_labels();
     51
     52                $this->assertSame( 'Replies', $labels['name'] );
     53                $this->assertSame( 'Reply', $labels['singular_name'] );
     54                $this->assertSame( 'Add Reply', $labels['add_new_item'] );
     55                $this->assertSame( 'Parent Topic:', $labels['parent_item_colon'] );
     56                $this->assertSame( 'Reply updated.', $labels['item_updated'] );
    5557        }
    5658
    5759        /**
    5860         * @covers ::bbp_get_reply_post_type_rewrite
    59          * @todo   Implement test_bbp_get_reply_post_type_rewrite().
    6061         */
    6162        public function test_bbp_get_reply_post_type_rewrite() {
    62                 // Remove the following lines when you implement this test.
    63                 $this->markTestIncomplete(
    64                         'This test has not been implemented yet.'
    65                 );
     63                $this->assertSame( array(
     64                        'slug'       => bbp_get_reply_slug(),
     65                        'with_front' => false,
     66                ), bbp_get_reply_post_type_rewrite() );
    6667        }
    6768
    6869        /**
    6970         * @covers ::bbp_get_reply_post_type_supports
    70          * @todo   Implement test_bbp_get_reply_post_type_supports().
    7171         */
    7272        public function test_bbp_get_reply_post_type_supports() {
    73                 // Remove the following lines when you implement this test.
    74                 $this->markTestIncomplete(
    75                         'This test has not been implemented yet.'
    76                 );
     73                $this->assertSame( array( 'title', 'editor', 'revisions' ), bbp_get_reply_post_type_supports() );
    7774        }
    7875}
  • trunk/tests/phpunit/testcases/topics/template/loop.php

    r5725 r7780  
    1212        /**
    1313         * @covers ::bbp_has_topics
    14          * @todo   Implement test_bbp_has_topics().
    1514         */
    1615        public function test_bbp_has_topics() {
    17                 // Remove the following lines when you implement this test.
    18                 $this->markTestIncomplete(
    19                         'This test has not been implemented yet.'
    20                 );
     16                $forum_id = $this->factory->forum->create();
     17                $topic_id = $this->factory->topic->create( array( 'post_parent' => $forum_id ) );
     18
     19                $this->assertTrue( bbp_has_topics( array(
     20                        'post_parent'    => $forum_id,
     21                        'posts_per_page' => -1,
     22                ) ) );
     23                $this->assertSame( 1, bbpress()->topic_query->post_count );
     24                $this->assertSame( $topic_id, bbpress()->topic_query->posts[0]->ID );
     25                $this->assertFalse( bbp_has_topics( array( 'post_parent' => $topic_id ) ) );
    2126        }
    2227
    2328        /**
    2429         * @covers ::bbp_topics
    25          * @todo   Implement test_bbp_topics().
    2630         */
    2731        public function test_bbp_topics() {
    28                 // Remove the following lines when you implement this test.
    29                 $this->markTestIncomplete(
    30                         'This test has not been implemented yet.'
    31                 );
     32                $forum_id = $this->factory->forum->create();
     33                $this->factory->topic->create( array( 'post_parent' => $forum_id ) );
     34                bbp_has_topics( array( 'post_parent' => $forum_id ) );
     35
     36                $this->assertTrue( bbp_topics() );
     37                bbp_the_topic();
     38                $this->assertFalse( bbp_topics() );
    3239        }
    3340
    3441        /**
    3542         * @covers ::bbp_the_topic
    36          * @todo   Implement test_bbp_the_topic().
    3743         */
    3844        public function test_bbp_the_topic() {
    39                 // Remove the following lines when you implement this test.
    40                 $this->markTestIncomplete(
    41                         'This test has not been implemented yet.'
    42                 );
     45                $forum_id = $this->factory->forum->create();
     46                $topic_id = $this->factory->topic->create( array( 'post_parent' => $forum_id ) );
     47                bbp_has_topics( array( 'post_parent' => $forum_id ) );
     48
     49                $this->assertTrue( bbp_topics() );
     50                bbp_the_topic();
     51                $this->assertSame( $topic_id, get_the_ID() );
     52                $this->assertFalse( bbp_topics() );
    4353        }
    4454}
  • trunk/tests/phpunit/testcases/topics/template/post_type.php

    r6071 r7780  
    4040        /**
    4141         * @covers ::bbp_get_topic_post_type_labels
    42          * @todo   Implement test_bbp_get_topic_post_type_labels().
    4342         */
    4443        public function test_bbp_get_topic_post_type_labels() {
    45                 // Remove the following lines when you implement this test.
    46                 $this->markTestIncomplete(
    47                         'This test has not been implemented yet.'
    48                 );
     44                $labels = bbp_get_topic_post_type_labels();
     45
     46                $this->assertSame( 'Topics', $labels['name'] );
     47                $this->assertSame( 'Topic', $labels['singular_name'] );
     48                $this->assertSame( 'Add Topic', $labels['add_new_item'] );
     49                $this->assertSame( 'Forum:', $labels['parent_item_colon'] );
     50                $this->assertSame( 'Topic updated.', $labels['item_updated'] );
    4951        }
    5052
    5153        /**
    5254         * @covers ::bbp_get_topic_post_type_rewrite
    53          * @todo   Implement test_bbp_get_topic_post_type_rewrite().
    5455         */
    5556        public function test_bbp_get_topic_post_type_rewrite() {
    56                 // Remove the following lines when you implement this test.
    57                 $this->markTestIncomplete(
    58                         'This test has not been implemented yet.'
    59                 );
     57                $this->assertSame( array(
     58                        'slug'       => bbp_get_topic_slug(),
     59                        'with_front' => false,
     60                ), bbp_get_topic_post_type_rewrite() );
    6061        }
    6162
    6263        /**
    6364         * @covers ::bbp_get_topic_post_type_supports
    64          * @todo   Implement test_bbp_get_topic_post_type_supports().
    6565         */
    6666        public function test_bbp_get_topic_post_type_supports() {
    67                 // Remove the following lines when you implement this test.
    68                 $this->markTestIncomplete(
    69                         'This test has not been implemented yet.'
    70                 );
     67                $this->assertSame( array( 'title', 'editor', 'revisions' ), bbp_get_topic_post_type_supports() );
    7168        }
    7269}
Note: See TracChangeset for help on using the changeset viewer.