From 88c16dfee3c6db1d79a0bf10b08e4047627c0a39 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Jan 2020 12:39:36 +0100 Subject: [PATCH] Bug 23443: Add tests Content-Type: text/plain; charset=utf-8 Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Marcel de Rooy --- t/db_dependent/Koha/Account.t | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index 85ddb5eb50..5437f16403 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -712,7 +712,7 @@ subtest 'pay() tests' => sub { subtest 'pay() handles lost items when paying a specific lost fee' => sub { - plan tests => 4; + plan tests => 5; $schema->storage->txn_begin; @@ -780,6 +780,49 @@ subtest 'pay() handles lost items when paying a specific lost fee' => sub { $checkout = Koha::Checkouts->find( $checkout->id ); ok( !$checkout, 'Item was removed from patron account' ); + subtest 'item was not checked out to the same patron' => sub { + plan tests => 1; + + my $patron_2 = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $library->branchcode } + } + ); + $item->itemlost('1')->store(); + C4::Accounts::chargelostitem( $patron->borrowernumber, $item->itemnumber, 5, "lost" ); + my $accountline = Koha::Account::Lines->search( + { + borrowernumber => $patron->borrowernumber, + itemnumber => $item->itemnumber, + debit_type_code => 'LOST' + } + )->next; + my $checkout = Koha::Checkout->new( + { + borrowernumber => $patron_2->borrowernumber, + itemnumber => $item->itemnumber, + date_due => \'NOW()', + branchcode => $patron_2->branchcode, + issuedate => \'NOW()', + } + )->store(); + + $patron->account->pay( + { + amount => 5, + library_id => $library->branchcode, + lines => [$accountline], + } + ); + + ok( + Koha::Checkouts->find( $checkout->issue_id ), + 'If the item is checked out to another patron, a lost item should not be returned if lost fee is paid' + ); + + }; + $schema->storage->txn_rollback; }; -- 2.11.0