Repository navigation
Tests: Cover next_post_rel_link() and prev_post_rel_link() #15323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Tests for get_adjacent_post_rel_link(), adjacent_posts_rel_link(), and adjacent_posts_rel_link_wp_head(). | ||
| * Tests for get_adjacent_post_rel_link(), adjacent_posts_rel_link(), adjacent_posts_rel_link_wp_head(), | ||
| * next_post_rel_link(), and prev_post_rel_link(). | ||
| * | ||
| * @group link | ||
| * @covers ::get_adjacent_post_rel_link | ||
| * @covers ::adjacent_posts_rel_link | ||
| * @covers ::adjacent_posts_rel_link_wp_head | ||
| * @covers ::next_post_rel_link | ||
| * @covers ::prev_post_rel_link | ||
| */ | ||
| class Tests_Link_GetAdjacentPostRelLink extends WP_UnitTestCase { | ||
|
|
||
|
|
@@ -128,4 +131,38 @@ public function test_adjacent_posts_rel_link_wp_head_outputs_nothing_when_not_si | |
| $this->expectOutputString( '' ); | ||
| adjacent_posts_rel_link_wp_head(); | ||
| } | ||
|
|
||
| /** | ||
| * Tests next_post_rel_link() outputs relational link for next post. | ||
| * | ||
| * @ticket 65819 | ||
| * | ||
| * @covers ::next_post_rel_link | ||
| */ | ||
| public function test_next_post_rel_link() { | ||
| $this->set_permalink_structure( '' ); | ||
| $this->go_to( get_permalink( self::$post_ids[1] ) ); | ||
|
|
||
| $expected = "<link rel='next' title='Third Post' href='" . home_url( '?p=' . self::$post_ids[2] ) . "' />\n"; | ||
|
|
||
| $this->expectOutputString( $expected ); | ||
| next_post_rel_link(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one looks like a small coverage gap: both tests use the defaults, so they still pass if |
||
| } | ||
|
|
||
| /** | ||
| * Tests prev_post_rel_link() outputs relational link for previous post. | ||
| * | ||
| * @ticket 65819 | ||
| * | ||
| * @covers ::prev_post_rel_link | ||
| */ | ||
| public function test_prev_post_rel_link() { | ||
| $this->set_permalink_structure( '' ); | ||
| $this->go_to( get_permalink( self::$post_ids[1] ) ); | ||
|
|
||
| $expected = "<link rel='prev' title='First Post' href='" . home_url( '?p=' . self::$post_ids[0] ) . "' />\n"; | ||
|
|
||
| $this->expectOutputString( $expected ); | ||
| prev_post_rel_link(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: the class docblock already has these
@coverstags. Feel free to drop this one and the one at line 157.