From 16209a75f54a1fcc7819adb66acb86348723d531 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 27 Mar 2019 14:56:52 +0000 Subject: [PATCH] Bug 22563: (follow-up) Corrections for tests Signed-off-by: Martin Renvoize --- t/db_dependent/Circulation.t | 41 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index b3887c8d73..375562c1ab 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2007,7 +2007,7 @@ subtest '_FixAccountForLostAndReturned' => sub { subtest 'Full write-off tests' => sub { - plan tests => 10; + plan tests => 11; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $manager = $builder->build_object({ class => "Koha::Patrons" }); @@ -2041,9 +2041,9 @@ subtest '_FixAccountForLostAndReturned' => sub { { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } ); is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); my $lost_fee_line = $lost_fee_lines->next; - is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); + is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' ); is( $lost_fee_line->amountoutstanding + 0, - $replacement_amount, 'The right L amountoutstanding is generated' ); + $replacement_amount, 'The right LOST amountoutstanding is generated' ); my $account = $patron->account; my $debts = $account->outstanding_debits; @@ -2063,14 +2063,15 @@ subtest '_FixAccountForLostAndReturned' => sub { $lost_fee_line->discard_changes; # reload from DB is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); is( $lost_fee_line->accounttype, - 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); + 'LOST', 'Lost fee now still has account type of LOST' ); + is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED"); is( $patron->account->balance, -0, 'The patron balance is 0, everything was written off' ); }; subtest 'Full payment tests' => sub { - plan tests => 12; + plan tests => 13; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); @@ -2102,9 +2103,9 @@ subtest '_FixAccountForLostAndReturned' => sub { { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } ); is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); my $lost_fee_line = $lost_fee_lines->next; - is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); + is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' ); is( $lost_fee_line->amountoutstanding + 0, - $replacement_amount, 'The right L amountountstanding is generated' ); + $replacement_amount, 'The right LOST amountountstanding is generated' ); my $account = $patron->account; my $debts = $account->outstanding_debits; @@ -2130,7 +2131,8 @@ subtest '_FixAccountForLostAndReturned' => sub { $lost_fee_line->discard_changes; is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); is( $lost_fee_line->accounttype, - 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); + 'LOST', 'Lost fee now still has account type of LOST' ); + is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED"); is( $patron->account->balance, -99, 'The patron balance is -99, a credit that equals the lost fee payment' ); @@ -2138,7 +2140,7 @@ subtest '_FixAccountForLostAndReturned' => sub { subtest 'Test without payment or write off' => sub { - plan tests => 12; + plan tests => 13; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); @@ -2171,9 +2173,9 @@ subtest '_FixAccountForLostAndReturned' => sub { { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } ); is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); my $lost_fee_line = $lost_fee_lines->next; - is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); + is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' ); is( $lost_fee_line->amountoutstanding + 0, - $replacement_amount, 'The right L amountountstanding is generated' ); + $replacement_amount, 'The right LOST amountountstanding is generated' ); my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id ); my $credit_return = Koha::Account::Lines->find($credit_return_id); @@ -2184,14 +2186,16 @@ subtest '_FixAccountForLostAndReturned' => sub { $lost_fee_line->discard_changes; is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); - is( $lost_fee_line->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); + is( $lost_fee_line->accounttype, + 'LOST', 'Lost fee now still has account type of LOST' ); + is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED"); is( $patron->account->balance, 20, 'The patron balance is 20, still owes the processing fee' ); }; subtest 'Test with partial payement and write off, and remaining debt' => sub { - plan tests => 15; + plan tests => 16; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $item = $builder->build_sample_item( @@ -2222,9 +2226,9 @@ subtest '_FixAccountForLostAndReturned' => sub { { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } ); is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); my $lost_fee_line = $lost_fee_lines->next; - is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); + is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' ); is( $lost_fee_line->amountoutstanding + 0, - $replacement_amount, 'The right L amountountstanding is generated' ); + $replacement_amount, 'The right LOST amountountstanding is generated' ); my $account = $patron->account; is( $account->balance, $processfee_amount + $replacement_amount, 'Balance is PF + L' ); @@ -2267,7 +2271,8 @@ subtest '_FixAccountForLostAndReturned' => sub { $lost_fee_line->discard_changes; is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); is( $lost_fee_line->accounttype, - 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); + 'LOST', 'Lost fee now still has account type of LOST' ); + is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED"); is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); is( $credit_return->amount + 0, @@ -2325,9 +2330,9 @@ subtest '_FixAccountForLostAndReturned' => sub { { borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'LOST' } ); is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); my $lost_fee_line = $lost_fee_lines->next; - is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); + is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' ); is( $lost_fee_line->amountoutstanding + 0, - $replacement_amount, 'The right L amountountstanding is generated' ); + $replacement_amount, 'The right LOST amountountstanding is generated' ); my $account = $patron->account; is( $account->balance, $replacement_amount, 'Balance is L' ); -- 2.20.1