From cdb2ec7bcc089d980829a2b82adb25c5c46fd20a 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 --- t/db_dependent/Circulation.t | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 3b0b09b83f..10b78600a3 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 => 57; +use Test::More tests => 58; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -1909,6 +1909,43 @@ subtest 'AddIssue & AllowReturnToBranch' => sub { # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); }; +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.25.1