| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @group link |
| 5 | * @covers ::get_feed_link |
| 6 | */ |
| 7 | class Tests_Link_GetFeedLink extends WP_UnitTestCase { |
| 8 | |
| 9 | /** |
| 10 | * @ticket 51839 |
| 11 | * @dataProvider data_plain_permastruct |
| 12 | * |
| 13 | * @param string $expected Expected suffix to home_url(). |
| 14 | * @param string $type Feed type to request. |
| 15 | */ |
| 16 | public function tests_plain_permastruct( $expected, $type ) { |
| 17 | $this->set_permalink_structure( '' ); |
| 18 | |
| 19 | $this->assertSame( home_url( $expected ), get_feed_link( $type ) ); |
| 20 | } |
| 21 | |
| 22 | public function data_plain_permastruct() { |
| 23 | return array( |
| 24 | array( '?feed=rss2', '' ), |
| 25 | array( '?feed=atom', 'atom' ), |
| 26 | array( '?feed=get-feed-link', 'get-feed-link' ), |
| 27 | array( '?feed=comments-rss2', 'comments_rss2' ), |
| 28 | array( '?feed=comments-atom', 'comments_atom' ), |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @ticket 51839 |
| 34 | * @dataProvider data_pretty_permastruct |
| 35 | * |
| 36 | * @param string $expected Expected suffix to home_url(). |
| 37 | * @param string $type Feed type to request. |
| 38 | */ |
| 39 | public function tests_pretty_permastruct( $expected, $type ) { |
| 40 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
| 41 | |
| 42 | $this->assertSame( home_url( $expected ), get_feed_link( $type ) ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @ticket 51839 |
| 47 | * @dataProvider data_pretty_permastruct |
| 48 | * |
| 49 | * @param string $expected Expected suffix to home_url(). |
| 50 | * @param string $type Feed type to request. |
| 51 | */ |
| 52 | public function tests_pretty_permastruct_with_prefix( $expected, $type ) { |
| 53 | $this->set_permalink_structure( '/archives/%post_id%/%postname%/' ); |
| 54 | |
| 55 | $this->assertSame( home_url( $expected ), get_feed_link( $type ) ); |
| 56 | } |
| 57 | |
| 58 | public function data_pretty_permastruct() { |
| 59 | return array( |
| 60 | array( '/feed/', '' ), |
| 61 | array( '/feed/atom/', 'atom' ), |
| 62 | array( '/feed/get-feed-link/', 'get-feed-link' ), |
| 63 | array( '/comments/feed/', 'comments_rss2' ), |
| 64 | array( '/comments/feed/atom/', 'comments_atom' ), |
| 65 | ); |
| 66 | } |
| 67 | } |