Bug 33837: Add unit test

Test plan:
Run t/db_dependent/Koha/Objects.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-05-25 14:25:32 +00:00 committed by Tomas Cohen Arazi
parent 47288e2336
commit d3e286b204
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 13 additions and 0 deletions

View File

@ -1188,6 +1188,19 @@ subtest "filter_by_last_update" => sub {
);
};
subtest 'Parameter datetime' => sub {
my $now = dt_from_string();
my $rs = Koha::Patrons->search({ borrowernumber => { -in => \@borrowernumbers } } );
$rs->update({ updated_on => $now->clone->subtract( hours => 25 ) });
is( $rs->filter_by_last_update({ timestamp_column_name => 'updated_on', from => $now })->count, 0, 'All updated yesterday' );
is( $rs->filter_by_last_update({ timestamp_column_name => 'updated_on', from => $now->clone->subtract( days => 1 ) })->count,
6, 'Yesterday, truncated from is inclusive' );
is( $rs->filter_by_last_update({ timestamp_column_name => 'updated_on', from => $now->clone->subtract( days => 1 ),
datetime => 1 })->count, 0, 'Yesterday, not truncated, one hour too late' );
is( $rs->filter_by_last_update({ timestamp_column_name => 'updated_on', from => $now->clone->subtract( hours => 25 ),
datetime => 1 })->count, 6, 'Yesterday - 1h, not truncated, within time frame' );
};
$schema->storage->txn_rollback;
};