From eae89c600fb93f3ef4babd129fc392ea75ddf43d Mon Sep 17 00:00:00 2001 From: William Jacoby Date: Wed, 14 Oct 2026 23:21:48 -0500 Subject: [PATCH] Read the clock once in the edit lock's start-time test The test compared a time read when the row was inserted with time() read again at the check, so it failed when a second passed in between, as it did on a slow SQL Server runner. assertSame takes no tolerance, so the extra argument meant to allow for that did nothing. Co-Authored-By: Claude Opus 5.5 --- tests/wiki/edit_lock_test.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/wiki/edit_lock_test.php b/tests/wiki/edit_lock_test.php index 627b1d1..1bed3d3 100644 --- a/tests/wiki/edit_lock_test.php +++ b/tests/wiki/edit_lock_test.php @@ -104,14 +104,17 @@ public function test_after_switching_to_the_lock_the_first_editor_keeps_the_arti public function test_taking_again_keeps_when_the_editor_started() { $lock = $this->lock(); + // Read the clock once: a second can pass before the checks on a slow runner + $started = time() - 600; + $old_expiry = time() + 60; $this->db->sql_query('INSERT INTO phpbb_wiki_edit_lock ' . $this->db->sql_build_array('INSERT', array( - 'article_url' => 'Main Page', 'user_id' => 2, 'lock_time' => time() - 600, 'lock_expires' => time() + 60, 'blocked_notified' => 0, + 'article_url' => 'Main Page', 'user_id' => 2, 'lock_time' => $started, 'lock_expires' => $old_expiry, 'blocked_notified' => 0, ))); $lock->take('Main Page', 2); $others = $lock->others('Main Page', 3); - $this->assertSame(time() - 600, (int) $others[0]['lock_time'], 'the start time is kept', 2); - $this->assertGreaterThan(time() + 60, (int) $others[0]['lock_expires']); + $this->assertSame($started, (int) $others[0]['lock_time'], 'the start time is kept'); + $this->assertGreaterThan($old_expiry, (int) $others[0]['lock_expires']); } public function test_a_record_that_ran_out_keeps_nobody_out_and_is_cleared()