Changeset 61066 for trunk/tests/phpunit/tests/url.php
- Timestamp:
- 10/26/2025 09:19:07 PM (13 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/url.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/url.php
r60253 r61066 570 570 } 571 571 } 572 573 /** 574 * Test get_adjacent_post with posts having identical post_date. 575 * 576 * @ticket 8107 577 * @covers ::get_adjacent_post 578 */ 579 public function test_get_adjacent_post_with_identical_dates() { 580 $identical_date = gmdate( 'Y-m-d H:i:s', time() ); 581 582 // Create 3 posts with identical dates but different IDs. 583 $post_ids = array(); 584 for ( $i = 1; $i <= 3; $i++ ) { 585 $post_ids[] = self::factory()->post->create( 586 array( 587 'post_title' => "Identical Post $i", 588 'post_date' => $identical_date, 589 ) 590 ); 591 } 592 593 // Test from the middle post (2nd post). 594 $GLOBALS['post'] = get_post( $post_ids[1] ); 595 596 // Previous post should be the 1st post (lower ID, same date). 597 $previous = get_adjacent_post( false, '', true ); 598 $this->assertInstanceOf( 'WP_Post', $previous ); 599 $this->assertSame( $post_ids[0], $previous->ID ); 600 601 // Next post should be the 3rd post (higher ID, same date). 602 $next = get_adjacent_post( false, '', false ); 603 $this->assertInstanceOf( 'WP_Post', $next ); 604 $this->assertSame( $post_ids[2], $next->ID ); 605 606 // Test from the first post. 607 $GLOBALS['post'] = get_post( $post_ids[0] ); 608 609 // Previous should be empty (no earlier posts). 610 $previous = get_adjacent_post( false, '', true ); 611 $this->assertSame( '', $previous ); 612 613 // Next should be the 2nd post. 614 $next = get_adjacent_post( false, '', false ); 615 $this->assertInstanceOf( 'WP_Post', $next ); 616 $this->assertSame( $post_ids[1], $next->ID ); 617 618 // Test from the last post. 619 $GLOBALS['post'] = get_post( $post_ids[2] ); 620 621 // Previous should be the 2nd post. 622 $previous = get_adjacent_post( false, '', true ); 623 $this->assertInstanceOf( 'WP_Post', $previous ); 624 $this->assertSame( $post_ids[1], $previous->ID ); 625 626 // Next should be empty (no later posts). 627 $next = get_adjacent_post( false, '', false ); 628 $this->assertSame( '', $next ); 629 } 572 630 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)