From 8cb1f1ecd1d854894b09b568b5ccad03ce13f9f4 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Tue, 6 Jan 2026 11:51:07 +0100 Subject: [PATCH] Tests: update tests to account for different month durations Fixes #2723 --- .github/changelog/fix-purge-ap-posts-test-date-boundary | 4 ++++ tests/phpunit/tests/includes/class-test-scheduler.php | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .github/changelog/fix-purge-ap-posts-test-date-boundary diff --git a/.github/changelog/fix-purge-ap-posts-test-date-boundary b/.github/changelog/fix-purge-ap-posts-test-date-boundary new file mode 100644 index 000000000..f79693e6f --- /dev/null +++ b/.github/changelog/fix-purge-ap-posts-test-date-boundary @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed flaky test for purge_ap_posts due to date boundary condition with -1 month diff --git a/tests/phpunit/tests/includes/class-test-scheduler.php b/tests/phpunit/tests/includes/class-test-scheduler.php index 80823b45e..5624f073c 100644 --- a/tests/phpunit/tests/includes/class-test-scheduler.php +++ b/tests/phpunit/tests/includes/class-test-scheduler.php @@ -703,7 +703,7 @@ public function test_cleanup_remote_actors() { * @covers ::purge_ap_posts */ public function test_purge_ap_posts_more_than_200_posts() { - // Create 20 posts older than 6 months (will be deleted). + // Create 20 posts older than 30 days (will be deleted). self::factory()->post->create_many( 20, array( @@ -713,13 +713,13 @@ public function test_purge_ap_posts_more_than_200_posts() { ) ); - // Create 5 posts newer than 6 months (will be kept). + // Create 5 posts newer than 30 days (will be kept). self::factory()->post->create_many( 5, array( 'post_type' => Posts::POST_TYPE, 'post_status' => 'publish', - 'post_date' => \gmdate( 'Y-m-d H:i:s', \strtotime( '-1 month' ) ), + 'post_date' => \gmdate( 'Y-m-d H:i:s', \strtotime( '-1 week' ) ), ) );