From e3031084c56fde1f421b1d36f2217cbeee317fef Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 9 Feb 2022 23:07:35 +0000 Subject: [PATCH] Bug 24239: Unit tests Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall --- t/db_dependent/Circulation.t | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 1322e54fbb..a6393278ac 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -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 ); @@ -2146,6 +2146,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; -- 2.30.2