From 3da9a009083d611cf1db7ad3c381f12dfa1b9b63 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 12 Aug 2022 10:20:24 -0300 Subject: [PATCH] Give sticky posts an earlier date This way it will not be the first post by accident --- tests/php/indexables/TestPost.php | 38 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/php/indexables/TestPost.php b/tests/php/indexables/TestPost.php index d04256542e..f834b1903a 100644 --- a/tests/php/indexables/TestPost.php +++ b/tests/php/indexables/TestPost.php @@ -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(); @@ -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();