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
34 changes: 17 additions & 17 deletions tests/phpunit/tests/link/getAdjacentPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,14 @@ public function test_get_adjacent_post_term_array_processing_order() {

// Should find post_one (previous post that shares term1).
$this->assertInstanceOf( WP_Post::class, $result );
$this->assertEquals( $post1_id, $result->ID );
$this->assertSame( $post1_id, $result->ID );

// Test next post.
$result = get_adjacent_post( true, array( $term2_id ), false, 'wptests_tax' );

// Should find post_three (next post that shares term1).
$this->assertInstanceOf( WP_Post::class, $result );
$this->assertEquals( $post3_id, $result->ID );
$this->assertSame( $post3_id, $result->ID );
}

/**
Expand Down Expand Up @@ -614,12 +614,12 @@ public function test_get_adjacent_post_with_identical_dates() {
// Previous post should be the 2nd post (lower ID, same date).
$previous = get_adjacent_post( false, '', true );
$this->assertInstanceOf( 'WP_Post', $previous );
$this->assertEquals( $post_ids[1], $previous->ID );
$this->assertSame( $post_ids[1], $previous->ID );

// Next post should be the 4th post (higher ID, same date).
$next = get_adjacent_post( false, '', false );
$this->assertInstanceOf( 'WP_Post', $next );
$this->assertEquals( $post_ids[3], $next->ID );
$this->assertSame( $post_ids[3], $next->ID );
}

/**
Expand Down Expand Up @@ -661,38 +661,38 @@ public function test_get_adjacent_post_mixed_dates_with_identical_groups() {
// Previous should be the early post (different date).
$previous = get_adjacent_post( false, '', true );
$this->assertInstanceOf( 'WP_Post', $previous );
$this->assertEquals( $post_early, $previous->ID );
$this->assertSame( $post_early, $previous->ID );

// Next should be the second identical post (same date, higher ID).
$next = get_adjacent_post( false, '', false );
$this->assertInstanceOf( 'WP_Post', $next );
$this->assertEquals( $post_ids[1], $next->ID );
$this->assertSame( $post_ids[1], $next->ID );

// Test from middle identical post.
$this->go_to( get_permalink( $post_ids[1] ) );

// Previous should be the first identical post (same date, lower ID).
$previous = get_adjacent_post( false, '', true );
$this->assertInstanceOf( 'WP_Post', $previous );
$this->assertEquals( $post_ids[0], $previous->ID );
$this->assertSame( $post_ids[0], $previous->ID );

// Next should be the third identical post (same date, higher ID).
$next = get_adjacent_post( false, '', false );
$this->assertInstanceOf( 'WP_Post', $next );
$this->assertEquals( $post_ids[2], $next->ID );
$this->assertSame( $post_ids[2], $next->ID );

// Test from last identical post.
$this->go_to( get_permalink( $post_ids[2] ) );

// Previous should be the second identical post (same date, lower ID).
$previous = get_adjacent_post( false, '', true );
$this->assertInstanceOf( 'WP_Post', $previous );
$this->assertEquals( $post_ids[1], $previous->ID );
$this->assertSame( $post_ids[1], $previous->ID );

// Next should be the late post (different date).
$next = get_adjacent_post( false, '', false );
$this->assertInstanceOf( 'WP_Post', $next );
$this->assertEquals( $post_late, $next->ID );
$this->assertSame( $post_late, $next->ID );
}

/**
Expand All @@ -719,26 +719,26 @@ public function test_get_adjacent_post_navigation_through_identical_dates() {

// From post 1, next should be post 2.
$next = get_adjacent_post( false, '', false );
$this->assertEquals( $post_ids[1], $next->ID );
$this->assertSame( $post_ids[1], $next->ID );

// From post 2, previous should be post 1, next should be post 3.
$this->go_to( get_permalink( $post_ids[1] ) );
$previous = get_adjacent_post( false, '', true );
$this->assertEquals( $post_ids[0], $previous->ID );
$this->assertSame( $post_ids[0], $previous->ID );
$next = get_adjacent_post( false, '', false );
$this->assertEquals( $post_ids[2], $next->ID );
$this->assertSame( $post_ids[2], $next->ID );

// From post 3, previous should be post 2, next should be post 4.
$this->go_to( get_permalink( $post_ids[2] ) );
$previous = get_adjacent_post( false, '', true );
$this->assertEquals( $post_ids[1], $previous->ID );
$this->assertSame( $post_ids[1], $previous->ID );
$next = get_adjacent_post( false, '', false );
$this->assertEquals( $post_ids[3], $next->ID );
$this->assertSame( $post_ids[3], $next->ID );

// From post 4, previous should be post 3.
$this->go_to( get_permalink( $post_ids[3] ) );
$previous = get_adjacent_post( false, '', true );
$this->assertEquals( $post_ids[2], $previous->ID );
$this->assertSame( $post_ids[2], $previous->ID );
}

/**
Expand Down Expand Up @@ -777,6 +777,6 @@ public function test_get_adjacent_post_identical_dates_with_category() {

$next = get_adjacent_post( true, '', false, 'category' );
$this->assertInstanceOf( 'WP_Post', $next );
$this->assertEquals( $post_ids[3], $next->ID ); // Post 4 (in category)
$this->assertSame( $post_ids[3], $next->ID ); // Post 4 (in category)
}
}
Loading