Skip to:
Content

bbPress.org

Changeset 7819


Ignore:
Timestamp:
10/04/2026 05:55:21 PM (6 weeks ago)
Author:
johnjamesjacoby
Message:

Tests: Cover topic and reply RSS feeds.

Run feed renderers in isolated PHP subprocesses so their exits do not terminate PHPUnit. Assert RSS structure, public items, protected topic redaction, and private-topic reply exclusion.

In trunk, for 2.7.

See #3695.

Location:
trunk/tests/phpunit
Files:
2 added
2 edited

Legend:

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

    r7815 r7819  
    621621        /**
    622622         * @covers ::bbp_display_replies_feed_rss2
    623          * @todo   Implement test_bbp_display_replies_feed_rss2().
    624623         */
    625624        public function test_bbp_display_replies_feed_rss2() {
    626                 // Remove the following lines when you implement this test.
    627                 $this->markTestIncomplete(
    628                         'This test has not been implemented yet.'
    629                 );
     625                require_once dirname( __DIR__, 3 ) . '/includes/feed-rss2-test.php';
     626
     627                $feed  = new DOMDocument();
     628                $xml   = bbp_test_run_feed_rss2( 'replies' );
     629                $valid = $feed->loadXML( $xml );
     630                $this->assertTrue( $valid, $xml );
     631
     632                $items = $feed->getElementsByTagName( 'item' );
     633                $this->assertSame( 1, $items->length );
     634                $this->assertSame( 'Feed Test Reply', $items->item( 0 )->getElementsByTagName( 'title' )->item( 0 )->textContent );
     635                $this->assertStringContainsString( 'Feed test reply content', $items->item( 0 )->textContent );
     636                $this->assertStringNotContainsString( 'Private Feed Reply', $xml );
     637                $this->assertStringNotContainsString( 'Private reply secret content', $xml );
    630638        }
    631639
  • trunk/tests/phpunit/testcases/topics/functions/topic.php

    r7811 r7819  
    930930        /**
    931931         * @covers ::bbp_display_topics_feed_rss2
    932          * @todo   Implement test_bbp_display_topics_feed_rss2().
    933932         */
    934933        public function test_bbp_display_topics_feed_rss2() {
    935                 // Remove the following lines when you implement this test.
    936                 $this->markTestIncomplete(
    937                         'This test has not been implemented yet.'
    938                 );
     934                require_once dirname( __DIR__, 3 ) . '/includes/feed-rss2-test.php';
     935
     936                $feed  = new DOMDocument();
     937                $xml   = bbp_test_run_feed_rss2( 'topics' );
     938                $valid = $feed->loadXML( $xml );
     939                $this->assertTrue( $valid, $xml );
     940
     941                $items = $feed->getElementsByTagName( 'item' );
     942                $this->assertSame( 2, $items->length );
     943                $by_title = array();
     944                foreach ( $items as $item ) {
     945                        $title = $item->getElementsByTagName( 'title' )->item( 0 )->textContent;
     946                        $by_title[ $title ] = $item;
     947                }
     948                $this->assertArrayHasKey( 'Feed Test Topic', $by_title );
     949                $this->assertArrayHasKey( 'Protected Feed Topic', $by_title );
     950                $this->assertStringContainsString( 'Feed test topic content', $by_title['Feed Test Topic']->textContent );
     951                $this->assertSame( 0, $by_title['Protected Feed Topic']->getElementsByTagName( 'description' )->length );
     952                $this->assertStringNotContainsString( 'Protected topic secret content', $xml );
    939953        }
    940954
Note: See TracChangeset for help on using the changeset viewer.