Bug 33611: Unit test

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Hinemoea Viault <hinemoea.viault@inlibro.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-04-27 13:02:24 +00:00 committed by Tomas Cohen Arazi
parent b614146972
commit 3551ef41a0
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -17,7 +17,7 @@
use Modern::Perl;
use Test::More tests => 77;
use Test::More tests => 78;
use Test::MockModule;
use Test::Warn;
@ -1735,3 +1735,29 @@ subtest 'CanItemBeReserved() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'DefaultHoldExpiration tests' => sub {
plan tests => 2;
$schema->storage->txn_begin;
t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdate', 1 );
t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdatePeriod', 365 );
t::lib::Mocks::mock_preference( 'DefaultHoldExpirationUnitOfTime', 'days;' );
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $item = $builder->build_sample_item();
my $reserve_id = AddReserve({
branchcode => $item->homebranch,
borrowernumber => $patron->id,
biblionumber => $item->biblionumber,
});
my $today = dt_from_string();
my $hold = Koha::Holds->find( $reserve_id );
is( $hold->reservedate, $today->ymd, "Hold created today" );
is( $hold->expirationdate, $today->add( days => 365)->ymd, "Reserve date set 1 year from today" );
$schema->txn_rollback;
};