From 0f9d197b3d4adc113d3cbeb1bbeb71c80f54af3c Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Fri, 18 Oct 2019 10:44:06 +0100 Subject: [PATCH] Bug 23051: (follow-up) Fix unit tests As raised by Nick in comment #35 --- Koha/Account/Line.pm | 4 +++- t/db_dependent/Koha/Account.t | 2 +- t/db_dependent/Koha/Account/Lines.t | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 3793eba733..767ef13cb8 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -248,7 +248,9 @@ sub apply { $debit->amountoutstanding, $debit ); - $overdue_unreturned->{$debit->itemnumber} = $debit if $renewable; + if ($renewable && $debit->itemnumber) { + $overdue_unreturned->{$debit->itemnumber} = $debit; + } # Same logic exists in Koha::Account::pay if ( $debit->amountoutstanding == 0 diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index 8e98136e63..47c95afea8 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 12; use Test::MockModule; use Test::Exception; diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index 4839017ca7..70131ef369 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -365,7 +365,7 @@ subtest 'apply() tests' => sub { my $module = new Test::MockModule('C4::Circulation'); $module->mock('AddRenewal', sub { $called = 1; }); my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' }); - my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id }); + my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list; $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } ); is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' ); -- 2.11.0