Bug 24239: Unit tests

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Lari Taskula 2022-02-09 23:07:35 +00:00 committed by Tomas Cohen Arazi
parent 60f3c899b8
commit 5b8e1d6f02
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -18,7 +18,7 @@
use Modern::Perl;
use utf8;
use Test::More tests => 60;
use Test::More tests => 61;
use Test::Exception;
use Test::MockModule;
use Test::Deep qw( cmp_deeply );
@ -2151,6 +2151,42 @@ subtest 'AddIssue | recalls' => sub {
AddReturn( $item->barcode, $item->homebranch );
};
subtest 'AddIssue & illrequests.date_due' => sub {
plan tests => 2;
t::lib::Mocks::mock_preference( 'ILLModule', 1 );
my $library = $builder->build( { source => 'Branch' } );
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $item = $builder->build_sample_item();
set_userenv($library);
my $custom_date_due = '9999-12-18 12:34:56';
my $expected_date_due = '9999-12-18 23:59:00';
my $illrequest = Koha::Illrequest->new({
borrowernumber => $patron->borrowernumber,
biblio_id => $item->biblionumber,
branchcode => $library->{'branchcode'},
date_due => $custom_date_due,
})->store;
my $issue = AddIssue( $patron->unblessed, $item->barcode );
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue');
$patron = $builder->build_object( { class => 'Koha::Patrons' } );
$item = $builder->build_sample_item();
$custom_date_due = '9999-12-19';
$expected_date_due = '9999-12-19 23:59:00';
$illrequest = Koha::Illrequest->new({
borrowernumber => $patron->borrowernumber,
biblio_id => $item->biblionumber,
branchcode => $library->{'branchcode'},
date_due => $custom_date_due,
})->store;
$issue = AddIssue( $patron->unblessed, $item->barcode );
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue');
};
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
plan tests => 8;