Skip to:
Content

bbPress.org

Changeset 7784


Ignore:
Timestamp:
10/04/2026 08:01:48 AM (5 weeks ago)
Author:
johnjamesjacoby
Message:

Tests: Cover remaining reply template helpers.

Replace three incomplete tests for reply lookup, CSS classes, and topic pagination counts. Check object and array lookup shapes and the corresponding output wrappers.

In trunk, for 2.7.

See #3695.

File:
1 edited

Legend:

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

    r6802 r7784  
    3737        /**
    3838         * @covers ::bbp_get_reply
    39          * @todo   Implement test_bbp_get_reply().
    4039         */
    4140        public function test_bbp_get_reply() {
    42                 // Remove the following lines when you implement this test.
    43                 $this->markTestIncomplete(
    44                         'This test has not been implemented yet.'
    45                 );
     41                $topic_id = $this->factory->topic->create();
     42                $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) );
     43                $forum_id = $this->factory->forum->create();
     44
     45                $this->assertSame( $reply_id, bbp_get_reply( $reply_id )->ID );
     46                $this->assertSame( $reply_id, bbp_get_reply( get_post( $reply_id ) )->ID );
     47                $this->assertSame( $reply_id, bbp_get_reply( $reply_id, ARRAY_A )['ID'] );
     48                $this->assertTrue( in_array( $reply_id, bbp_get_reply( $reply_id, ARRAY_N ), true ) );
     49                $this->assertNull( bbp_get_reply( $forum_id ) );
    4650        }
    4751
    … …  
    575579         * @covers ::bbp_reply_class
    576580         * @covers ::bbp_get_reply_class
    577          * @todo   Implement test_bbp_get_reply_class().
    578581         */
    579582        public function test_bbp_get_reply_class() {
    580                 // Remove the following lines when you implement this test.
    581                 $this->markTestIncomplete(
    582                         'This test has not been implemented yet.'
    583                 );
     583                $forum_id = $this->factory->forum->create();
     584                $topic_id = $this->factory->topic->create( array( 'post_parent' => $forum_id ) );
     585                $reply_id = $this->factory->reply->create( array( 'post_parent' => $topic_id ) );
     586                $classes  = bbp_get_reply_class( $reply_id, array( 'extra-reply-class' ) );
     587
     588                $this->assertStringContainsString( 'bbp-parent-topic-' . $topic_id, $classes );
     589                $this->assertStringContainsString( 'bbp-parent-forum-' . $forum_id, $classes );
     590                $this->assertStringContainsString( 'bbp-reply-position-', $classes );
     591                $this->assertStringContainsString( 'extra-reply-class', $classes );
     592                $this->expectOutputString( $classes );
     593                bbp_reply_class( $reply_id, array( 'extra-reply-class' ) );
    584594        }
    585595
    … …  
    587597         * @covers ::bbp_topic_pagination_count
    588598         * @covers ::bbp_get_topic_pagination_count
    589          * @todo   Implement test_bbp_get_topic_pagination_count().
    590599         */
    591600        public function test_bbp_get_topic_pagination_count() {
    592                 // Remove the following lines when you implement this test.
    593                 $this->markTestIncomplete(
    594                         'This test has not been implemented yet.'
    595                 );
     601                $topic_id = $this->factory->topic->create();
     602                $this->factory->reply->create_many( 2, array( 'post_parent' => $topic_id ) );
     603                bbp_has_replies( array( 'post_type' => bbp_get_reply_post_type(), 'post_parent' => $topic_id ) );
     604                $count = bbp_get_topic_pagination_count();
     605
     606                $this->assertStringContainsString( 'Viewing', $count );
     607                $this->assertStringContainsString( '2 total', $count );
     608                $this->expectOutputString( $count );
     609                bbp_topic_pagination_count();
    596610        }
    597611}
Note: See TracChangeset for help on using the changeset viewer.