From 0ffd2759a0959e22bceab8a1b8b7e869420b85bf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 4 Feb 2020 15:13:47 +0100 Subject: [PATCH] Bug 24474: Add tests This does the following using the interface: - Unselect all the options from MarkLostItemsAsReturned except for 'onpayment' - Check an item out - Create a manual invoice LOST for the checked in item - Renew the item - Check that the item was not returned Signed-off-by: David Nind Signed-off-by: David Nind Signed-off-by: Kyle M Hall --- t/db_dependent/Circulation.t | 44 +++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 104fc8fc85..f4a6c37092 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 => 46; +use Test::More tests => 47; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -3770,6 +3770,48 @@ subtest "Test Backdating of Returns" => sub { is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' ); }; +subtest 'Do not return on renewal (LOST charge)' => sub { + plan tests => 1; + + t::lib::Mocks::mock_preference('MarkLostItemsAsReturned', 'onpayment'); + my $library = $builder->build_object( { class => "Koha::Libraries" } ); + my $manager = $builder->build_object( { class => "Koha::Patrons" } ); + t::lib::Mocks::mock_userenv({ patron => $manager,branchcode => $manager->branchcode }); + + my $biblio = $builder->build_sample_biblio; + + my $item = $builder->build_sample_item( + { + biblionumber => $biblio->biblionumber, + library => $library->branchcode, + replacementprice => 99.00, + itype => $itemtype, + } + ); + + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + AddIssue( $patron->unblessed, $item->barcode ); + + my $accountline = Koha::Account::Line->new( + { + borrowernumber => $patron->borrowernumber, + debit_type_code => 'LOST', + status => undef, + itemnumber => $item->itemnumber, + amount => 12, + amountoutstanding => 12, + interface => 'something', + } + )->store(); + + # AddRenewal doesn't call _FixAccountForLostAndFound + AddIssue( $patron->unblessed, $item->barcode ); + + is( $patron->checkouts->count, 1, + 'Renewal should not return the item even if a LOST payment has been made earlier' + ); +}; + $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $cache->clear_from_cache('single_holidays'); -- 2.24.1 (Apple Git-126)