Use the current post's post type when determining post adjacency.

props ethitter.
fixes #26937.


git-svn-id: https://develop.svn.wordpress.org/trunk@27692 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-03-24 21:29:14 +00:00
parent 4983a8b8d0
commit 05f0bcabec
2 changed files with 25 additions and 5 deletions
+24 -4
View File
@@ -175,22 +175,35 @@ class Tests_Link extends WP_UnitTestCase {
// Need some sample posts to test adjacency
$post_one = $this->factory->post->create_and_get( array(
'post_title' => 'First',
'post_date' => '2012-01-01 12:00:00'
'post_date' => '2012-01-01 12:00:00',
) );
$post_two = $this->factory->post->create_and_get( array(
'post_title' => 'Second',
'post_date' => '2012-02-01 12:00:00'
'post_date' => '2012-02-01 12:00:00',
) );
$post_three = $this->factory->post->create_and_get( array(
'post_title' => 'Third',
'post_date' => '2012-03-01 12:00:00'
'post_date' => '2012-03-01 12:00:00',
) );
$post_four = $this->factory->post->create_and_get( array(
'post_title' => 'Fourth',
'post_date' => '2012-04-01 12:00:00'
'post_date' => '2012-04-01 12:00:00',
) );
// Use pages to test post-type adjacency
$page_one = $this->factory->post->create_and_get( array(
'post_title' => 'First Page',
'post_date' => '2013-01-01 12:00:00',
'post_type' => 'page',
) );
$page_two = $this->factory->post->create_and_get( array(
'post_title' => 'Second Page',
'post_date' => '2013-02-01 12:00:00',
'post_type' => 'page',
) );
// Add some meta so we can join the postmeta table and query
@@ -233,6 +246,13 @@ class Tests_Link extends WP_UnitTestCase {
$this->go_to( get_permalink( $post_one->ID ) );
$this->assertEquals( $post_three, get_adjacent_post( false, null, false ) );
remove_filter( 'get_next_post_sort', array( $this, 'filter_next_post_sort_limit' ) );
// Test post-type specificity
$this->go_to( get_permalink( $page_one ) );
$this->assertEquals( $page_two, get_adjacent_post( false, null, false ) );
$this->go_to( get_permalink( $page_two ) );
$this->assertEquals( $page_one, get_adjacent_post( false, null, true ) );
}
/**