| 1 | <?php |
| 2 | /** |
| 3 | * Tests for the Feeds template components |
| 4 | * |
| 5 | * @group feed |
| 6 | */ |
| 7 | class Tests_Feeds_Template extends WP_UnitTestCase { |
| 8 | static $post_id; |
| 9 | |
| 10 | /** |
| 11 | * Setup a new user and attribute some posts. |
| 12 | */ |
| 13 | public static function wpSetUpBeforeClass( $factory ) { |
| 14 | self::$post_id = $factory->post->create(); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Setup. |
| 19 | */ |
| 20 | public function setUp() { |
| 21 | parent::setUp(); |
| 22 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Tests the RSS feed link |
| 27 | */ |
| 28 | function test_the_feed_link_rss() { |
| 29 | $expected = '<a rel="alternate" type="application/rss+xml" href="' . get_feed_link( 'rss' ) . '">feed</a>'; |
| 30 | ob_start(); |
| 31 | the_feed_link( 'feed', 'rss' ); |
| 32 | $actual = ob_get_clean(); |
| 33 | $this->assertEquals( $expected, $actual ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Tests Atom feed link |
| 38 | */ |
| 39 | function test_the_feed_link_atom() { |
| 40 | $expected = '<a rel="alternate" type="application/atom+xml" href="' . get_feed_link( 'atom' ) . '">feed</a>'; |
| 41 | ob_start(); |
| 42 | the_feed_link( 'feed', 'atom' ); |
| 43 | $actual = ob_get_clean(); |
| 44 | $this->assertEquals( $expected, $actual ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Tests RSS comments feed link |
| 49 | */ |
| 50 | function test_post_comments_feed_link_rss() { |
| 51 | $expected = '<a rel="alternate" type="application/rss+xml" href="' . get_post_comments_feed_link( self::$post_id, 'rss' ) . '">comments</a>'; |
| 52 | ob_start(); |
| 53 | post_comments_feed_link( 'comments', self::$post_id, 'rss' ); |
| 54 | $actual = ob_get_clean(); |
| 55 | $this->assertEquals( $expected, $actual ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Tests Atom comments feed link |
| 60 | */ |
| 61 | function test_post_comments_feed_link_atom() { |
| 62 | $expected = '<a rel="alternate" type="application/atom+xml" href="' . get_post_comments_feed_link( self::$post_id, 'atom' ) . '">comments</a>'; |
| 63 | ob_start(); |
| 64 | post_comments_feed_link( 'comments', self::$post_id, 'atom' ); |
| 65 | $actual = ob_get_clean(); |
| 66 | $this->assertEquals( $expected, $actual ); |
| 67 | } |
| 68 | } |