Index: tests/phpunit/testcases/topics/functions/topic.php
===================================================================
--- tests/phpunit/testcases/topics/functions/topic.php	(revision 5952)
+++ tests/phpunit/testcases/topics/functions/topic.php	(working copy)
@@ -502,18 +502,188 @@
 		);
 	}
 
+	function do_rss2() {
+		ob_start();
+		// nasty hack
+		global $post;
+		try {
+			@require(ABSPATH . 'wp-includes/feed-rss2.php');
+			$out = ob_get_clean();
+		} catch (Exception $e) {
+			$out = ob_get_clean();
+			throw($e);
+		}
+		return $out;
+	}
+
 	/**
+	 * Test the rss element of a forum topics feed
+	 *
+	 * @group feeds
 	 * @covers ::bbp_display_topics_feed_rss2
-	 * @todo   Implement test_bbp_display_topics_feed_rss2().
 	 */
-	public function test_bbp_display_topics_feed_rss2() {
-		// Remove the following lines when you implement this test.
-		$this->markTestIncomplete(
-			'This test has not been implemented yet.'
-		);
+	public function test_bbp_display_topics_feed_rss2_rss() {
+		$f = $this->factory->forum->create();
+
+		$this->go_to( bbp_get_forum_permalink( $f ) . '&feed=rss2' );
+		$feed = $this->do_rss2();
+		$xml = xml_to_array( $feed );
+
+		// Get the rss element.
+		$rss = xml_find( $xml, 'rss' );
+
+		// There should only be one rss element.
+		$this->assertEquals( 1, count( $rss ) );
+
+		$this->assertEquals( '2.0',                                          $rss[0]['attributes']['version'] );
+		$this->assertEquals( 'http://purl.org/rss/1.0/modules/content/',     $rss[0]['attributes']['xmlns:content'] );
+		$this->assertEquals( 'http://wellformedweb.org/CommentAPI/',         $rss[0]['attributes']['xmlns:wfw'] );
+		$this->assertEquals( 'http://purl.org/dc/elements/1.1/',             $rss[0]['attributes']['xmlns:dc'] );
+		$this->assertEquals( 'http://www.w3.org/2005/Atom',                  $rss[0]['attributes']['xmlns:atom'] );
+		$this->assertEquals( 'http://purl.org/rss/1.0/modules/syndication/', $rss[0]['attributes']['xmlns:sy'] );
+		$this->assertEquals( 'http://purl.org/rss/1.0/modules/slash/',       $rss[0]['attributes']['xmlns:slash'] );
+
+		// RSS should have exactly one child element (channel).
+		$this->assertEquals( 1, count( $rss[0]['child'] ) );
 	}
 
 	/**
+	 * Test the channel element of a forum topics feed
+	 *
+	 * @group feeds
+	 * @covers ::bbp_display_topics_feed_rss2
+	 */
+	public function test_bbp_display_topics_feed_rss2_channel() {
+		$f = $this->factory->forum->create();
+
+		$this->go_to( bbp_get_forum_permalink( $f ) . '&feed=rss2' );
+
+		$feed = $this->do_rss2();
+		$xml = xml_to_array( $feed );
+
+		// Get the rss -> channel element.
+		$channel = xml_find( $xml, 'rss', 'channel' );
+
+		// There should only be one rss -> channel element.
+		$this->assertEquals( 1, count( $channel ) );
+
+		// The rss -> channel element should not have any attributes.
+		$this->assertTrue( empty( $channel[0]['attributes'] ) );
+
+		$title = xml_find( $xml, 'rss', 'channel', 'title' );
+		$this->assertEquals( get_option( 'blogname' ), $title[0]['content'] );
+
+		$link = xml_find( $xml, 'rss', 'channel', 'link' );
+		$this->assertEquals( get_option( 'siteurl' ), $link[0]['content'] );
+
+		$desc = xml_find( $xml, 'rss', 'channel', 'description' );
+		$this->assertEquals( get_option( 'blogdescription' ), $desc[0]['content'] );
+
+		$pubdate = xml_find( $xml, 'rss', 'channel', 'lastBuildDate' );
+		$this->assertEquals( strtotime( get_lastpostmodified() ), strtotime( $pubdate[0]['content'] ) );
+
+		$generator = xml_find( $xml, 'rss', 'channel', 'generator' );
+		$this->assertEquals( 'http://' . WP_TESTS_DOMAIN. bbp_get_version(), $generator[0]['content'] );
+
+		$language = xml_find( $xml, 'rss', 'channel', 'language' );
+		$this->assertEquals( get_bloginfo_rss( 'language' ), $language[0]['content'] );
+
+		$updatePeriod = xml_find( $xml, 'rss', 'channel', 'sy:updatePeriod' );
+		$duration = 'hourly';
+		$this->assertEquals( apply_filters( 'rss_update_period', $duration ), $updatePeriod[0]['content'] );
+
+		$updateFrequency = xml_find( $xml, 'rss', 'channel', 'sy:updateFrequency' );
+		$frequency = '1';
+		$this->assertEquals( apply_filters( 'updateFrequency', $frequency ), $updateFrequency[0]['content'] );
+	}
+
+	/**
+	 * Test the item elements of a forum topics feed
+	 *
+	 * @group feeds
+	 * @covers ::bbp_display_topics_feed_rss2
+	 */
+	public function test_bbp_display_topics_feed_rss2_items() {
+		$f = $this->factory->forum->create();
+
+		$t = $this->factory->topic->create_many( 2, array(
+			'post_parent' => $f,
+			'topic_meta' => array(
+				'forum_id' => $f,
+			),
+		) );
+
+		$r = $this->factory->reply->create_many( 2, array(
+			'post_parent' => $t[0],
+			'reply_meta' => array(
+				'forum_id' => $f,
+				'topic_id' => $t[0],
+			),
+		) );
+
+		$this->go_to( bbp_get_forum_permalink( $f ) . '&feed=rss2' );
+		$feed = $this->do_rss2();
+		$xml = xml_to_array( $feed );
+
+//var_dump( $this->do_rss2() );
+//var_dump( $xml );
+
+		// Get all the rss -> channel -> item elements.
+		$items = xml_find( $xml, 'rss', 'channel', 'item' );
+
+// var_dump( $items );
+
+		// Check each of the items against the known post data.
+		foreach ( $items as $key => $item ) {
+
+var_dump( $item );
+
+			// Get topic for comparison.
+			$guid = xml_find( $items[ $key ]['child'], 'guid' );
+			preg_match( '/\?p=(\d+)/', $guid[0]['content'], $matches );
+			$topic = bbp_get_topic( $matches[1] );
+
+			// Title.
+			$title = xml_find( $items[ $key ]['child'], 'title' );
+			$this->assertEquals( $topic->post_title, $title[0]['content'] );
+
+			// Link.
+			$link = xml_find( $items[ $key ]['child'], 'link' );
+			$this->assertEquals( get_permalink( $post ), $link[0]['content'] );
+
+			// Comment link.
+			$comments_link = xml_find( $items[ $key ]['child'], 'comments' );
+			$this->assertEquals( get_permalink( $post ) . '#respond', $comments_link[0]['content'] );
+
+			// Published date.
+			$pubdate = xml_find( $items[ $key ]['child'], 'pubDate' );
+			$this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) );
+
+			// Author.
+			$creator = xml_find( $items[ $key ]['child'], 'dc:creator' );
+			$user = new WP_User( $post->post_author );
+			$this->assertEquals( $user->user_login, $creator[0]['content'] );
+
+			// GUID.
+			$guid = xml_find( $items[ $key ]['child'], 'guid' );
+			$this->assertEquals( 'false', $guid[0]['attributes']['isPermaLink'] );
+			$this->assertEquals( $post->guid, $guid[0]['content'] );
+
+			// Description/excerpt.
+			if ( ! empty( $post->post_excerpt ) ) {
+				$description = xml_find( $items[ $key ]['child'], 'description' );
+				$this->assertEquals( trim( $post->post_excerpt ), trim( $description[0]['content'] ) );
+			}
+
+			// Topic content.
+			if ( ! $this->excerpt_only ) {
+				$content = xml_find( $items[ $key ]['child'], 'content:encoded' );
+				$this->assertEquals( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) );
+			}
+		}
+	}
+
+	/**
 	 * @covers ::bbp_check_topic_edit
 	 * @todo   Implement test_bbp_check_topic_edit().
 	 */
