Bug 42578: Prevent Koha/Hold.t to fail on date comparison

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 <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4da822b6a1)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-05-11 10:39:27 +02:00 committed by Jacob O'Mara
parent 8c66f2175d
commit 2eee1b9e9d
No known key found for this signature in database
1 changed files with 7 additions and 3 deletions

View File

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