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
This commit is contained in:
Sergey Biryukov 2024-02-11 17:02:46 +00:00
parent 44a2073816
commit fc4ad56061

View File

@ -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 ) );