From 2eee1b9e9d49765ffb56c68d7702631b682bbcfc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 11 May 2026 10:39:27 +0200 Subject: [PATCH] Bug 42578: Prevent Koha/Hold.t to fail on date comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We must use t::lib::Dates::compare to compare dates in test. Test plan: Confirm that `prove t/db_dependent/Koha/Hold.t` still returns green after this patch Signed-off-by: Tomás Cohen Arazi Signed-off-by: Lucas Gass (cherry picked from commit 4da822b6a145eda7f3befc4ac573b20a340b7618) Signed-off-by: Jacob O'Mara --- t/db_dependent/Koha/Hold.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t index 54fce19abb..c1536739e1 100755 --- a/t/db_dependent/Koha/Hold.t +++ b/t/db_dependent/Koha/Hold.t @@ -27,7 +27,7 @@ use Test::MockModule; use t::lib::Mocks; use t::lib::TestBuilder; -use t::lib::Mocks; +use t::lib::Dates; use C4::Reserves qw(AddReserve); @@ -1370,8 +1370,12 @@ subtest 'revert_found() tests' => sub { my $log = Koha::ActionLogs->search( { module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id } )->next; - my $expected = sprintf q{'timestamp' => '%s'}, $hold->timestamp; - like( $log->info, qr{$expected}, 'Timestamp logged is the current one' ); + if ( $log && $log->info =~ m{'timestamp' => '([^']*)'} ) { + my $timestamp = $1; + is( t::lib::Dates::compare( $timestamp, $hold->timestamp ), 0, 'Timestamp logged is the current one' ); + } else { + fail('Log entry for hold modification not found or malformed'); + } my $log_count = Koha::ActionLogs->search( { module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id } )->count;