From fc4ad56061723cc694116c7095915b8b7af693a5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 11 Feb 2024 17:02:46 +0000 Subject: [PATCH] Tests: Adjust the meta key time in `wp_scheduled_delete()` tests. Occasionally, the tests verifying that old trashed posts or comments are not deleted if not old enough can take longer than expected, leading to false positives when comparing the timestamp in `wp_scheduled_delete()`, and resulting in subsequent test failures. This commit aims to resolve the race condition. Follow-up to [57224], [57237]. See #59938. git-svn-id: https://develop.svn.wordpress.org/trunk@57583 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions/wpScheduledDelete.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpScheduledDelete.php b/tests/phpunit/tests/functions/wpScheduledDelete.php index d3f4d144aa..c7963578db 100644 --- a/tests/phpunit/tests/functions/wpScheduledDelete.php +++ b/tests/phpunit/tests/functions/wpScheduledDelete.php @@ -87,7 +87,7 @@ class Tests_Functions_wpScheduledDelete extends WP_UnitTestCase { 'post_status' => 'trash', ) ); - add_post_meta( self::$page_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ) ); + add_post_meta( self::$page_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS - 1 ) ); add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); @@ -157,7 +157,7 @@ class Tests_Functions_wpScheduledDelete extends WP_UnitTestCase { 'comment_approved' => 'trash', ) ); - add_comment_meta( self::$comment_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ) ); + add_comment_meta( self::$comment_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS - 1 ) ); add_comment_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) );