Skip to content

Commit 1eee2fe

Browse files
committed
Try stuff
1 parent 558e6e0 commit 1eee2fe

File tree

1 file changed

+66
-2
lines changed

1 file changed

+66
-2
lines changed

tests/phpunit/tests/query/deterministicOrdering.php

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ public function test_deterministic_ordering_prevents_duplicates_across_pages() {
3333
);
3434
}
3535

36+
sleep( 1 ); // Ensure modified time changes
37+
// Update every second post if we can trigger the error.
38+
for ( $i = 1; $i <= 20; $i += 2 ) {
39+
wp_update_post(
40+
array(
41+
'ID' => $post_ids[ $i - 1 ],
42+
'post_content' => "Updated post $i content",
43+
)
44+
);
45+
}
46+
3647
// Get first page
3748
$query1 = new WP_Query(
3849
array(
@@ -89,15 +100,26 @@ public function test_deterministic_ordering_with_post_title() {
89100
$post_ids = array();
90101

91102
for ( $i = 1; $i <= 15; $i++ ) {
92-
$post_day = str_pad( (string) $i, 2, '0', STR_PAD_LEFT );
93103
$post_ids[] = self::factory()->post->create(
94104
array(
95105
'post_title' => $identical_title,
96-
'post_date' => "2023-01-{$post_day} 10:00:00",
106+
'post_date' => "2023-01-0$i 10:00:00",
97107
)
98108
);
99109
}
100110

111+
sleep( 1 ); // Ensure modified time changes
112+
// Update every second post if we can trigger the error.
113+
for ( $i = 1; $i <= 15; $i += 2 ) {
114+
wp_update_post(
115+
array(
116+
'ID' => $post_ids[ $i - 1 ],
117+
'post_content' => "Updated post $i content",
118+
)
119+
);
120+
}
121+
122+
101123
// Get first page
102124
$query1 = new WP_Query(
103125
array(
@@ -144,6 +166,17 @@ public function test_deterministic_ordering_with_desc_order() {
144166
);
145167
}
146168

169+
sleep( 1 ); // Ensure modified time changes
170+
// Update every second post if we can trigger the error.
171+
for ( $i = 1; $i <= 12; $i += 2 ) {
172+
wp_update_post(
173+
array(
174+
'ID' => $post_ids[ $i - 1 ],
175+
'post_content' => "Updated post $i content",
176+
)
177+
);
178+
}
179+
147180
// Get first page with DESC order
148181
$query1 = new WP_Query(
149182
array(
@@ -189,6 +222,16 @@ public function test_deterministic_ordering_with_array_orderby() {
189222
)
190223
);
191224
}
225+
sleep( 1 ); // Ensure modified time changes
226+
// Update every second post if we can trigger the error.
227+
for ( $i = 1; $i <= 15; $i += 2 ) {
228+
wp_update_post(
229+
array(
230+
'ID' => $post_ids[ $i - 1 ],
231+
'post_content' => "Updated post $i content",
232+
)
233+
);
234+
}
192235

193236
// Test with array orderby
194237
$query1 = new WP_Query(
@@ -238,6 +281,16 @@ public function test_deterministic_ordering_does_not_duplicate_id() {
238281
)
239282
);
240283
}
284+
sleep( 1 ); // Ensure modified time changes
285+
// Update every second post if we can trigger the error.
286+
for ( $i = 1; $i <= 10; $i += 2 ) {
287+
wp_update_post(
288+
array(
289+
'ID' => $post_ids[ $i - 1 ],
290+
'post_content' => "Updated post $i content",
291+
)
292+
);
293+
}
241294

242295
$query = new WP_Query(
243296
array(
@@ -271,6 +324,17 @@ public function test_deterministic_ordering_with_search() {
271324
);
272325
}
273326

327+
sleep( 1 ); // Ensure modified time changes
328+
// Update every second post if we can trigger the error.
329+
for ( $i = 1; $i <= 12; $i += 2 ) {
330+
wp_update_post(
331+
array(
332+
'ID' => $post_ids[ $i - 1 ],
333+
'post_content' => "Updated test post $i content",
334+
)
335+
);
336+
}
337+
274338
// Test with search
275339
$query1 = new WP_Query(
276340
array(

0 commit comments

Comments
 (0)