Skip to content

Commit

Permalink
Merge pull request #2943 from 10up/tests/fix-sticky-posts
Browse files Browse the repository at this point in the history
Give sticky posts an earlier date
  • Loading branch information
felipeelia authored Aug 12, 2022
2 parents 7d04537 + 3da9a00 commit f934509
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions tests/php/indexables/TestPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -4459,10 +4459,23 @@ public function testCustomTaxonomyPublic() {
* @group post-sticky
*/
public function testStickyPostsIncludedOnHome() {
Functions\create_and_sync_post( array( 'post_title' => 'Normal post 1' ) );
$sticky_id = Functions\create_and_sync_post( array( 'post_title' => 'Sticky post' ) );
Functions\create_and_sync_post(
[
'post_title' => 'Normal post 1',
]
);
$sticky_id = Functions\create_and_sync_post(
[
'post_title' => 'Sticky post',
'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( '2 days ago' ) ),
]
);
stick_post( $sticky_id );
Functions\create_and_sync_post( array( 'post_title' => 'Normal post 2' ) );
Functions\create_and_sync_post(
[
'post_title' => 'Normal post 2',
]
);

ElasticPress\Elasticsearch::factory()->refresh_indices();

Expand All @@ -4480,10 +4493,23 @@ public function testStickyPostsIncludedOnHome() {
* @group post-sticky
*/
public function testStickyPostsExcludedOnNotHome() {
Functions\create_and_sync_post( array( 'post_title' => 'Normal post 1' ) );
$sticky_id = Functions\create_and_sync_post( array( 'post_title' => 'Sticky post' ) );
Functions\create_and_sync_post(
[
'post_title' => 'Normal post 1',
]
);
$sticky_id = Functions\create_and_sync_post(
[
'post_title' => 'Sticky post',
'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( '2 days ago' ) ),
]
);
stick_post( $sticky_id );
Functions\create_and_sync_post( array( 'post_title' => 'Normal post 2' ) );
Functions\create_and_sync_post(
[
'post_title' => 'Normal post 2',
]
);

ElasticPress\Elasticsearch::factory()->refresh_indices();

Expand Down

0 comments on commit f934509

Please sign in to comment.