Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion tests/phpunit/tests/link/getAdjacentPostRelLink.php
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 {

Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Member

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 @covers tags. Feel free to drop this one and the one at line 157.

*/
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();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 $title, $in_same_term or $excluded_terms stop being forwarded. Could you add a case with a custom title, like next_post_rel_link( 'Go to %title' ), and the same for prev_post_rel_link()?

}

/**
* 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();
}
}
Loading