From 3cbd9f0dc73d9b1f63c2c56f46ac4d37930ed101 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 24 Apr 2019 10:35:22 +0100 Subject: [PATCH] Bug 11573: Update of unit tests This patch updates the unit tests to reflect the changes to the core routines. The relevant changes are the removal of a hard coded 'description' and the splitting up of the 'Rent' accounttype into 'RENT', 'RENT_RENEW', 'RENT_DAILY' and 'RENT_DAILY_RENEW'. Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Nick Clemens --- t/db_dependent/Circulation.t | 29 ++++++++++++----------------- t/db_dependent/Circulation/Returns.t | 2 +- t/db_dependent/Circulation/issue.t | 2 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index bc1fa85128..84d46a2d0c 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -3093,7 +3093,7 @@ subtest 'AddReturn should clear items.onloan for unissued items' => sub { subtest 'AddRenewal and AddIssuingCharge tests' => sub { - plan tests => 13; + plan tests => 10; t::lib::Mocks::mock_preference('item-level_itypes', 1); @@ -3152,34 +3152,29 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub { # The following will fail if run on 00:00:00 unlike ( $checkouts->next->lastreneweddate, qr/00:00:00/, 'AddRenewal should set the renewal date with the time part'); - t::lib::Mocks::mock_preference( 'RenewalLog', 1 ); - $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); - $old_log_size = Koha::ActionLogs->count( \%params_renewal ); - AddRenewal( $patron->id, $item->id, $library->id ); - $new_log_size = Koha::ActionLogs->count( \%params_renewal ); - is( $new_log_size, $old_log_size + 1, 'renew log successfully added' ); - my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id, itemnumber => $item->id }); - is( $lines->count, 3 ); + is( $lines->count, 2 ); my $line = $lines->next; - is( $line->accounttype, 'Rent', 'The issuing charge generates an accountline' ); + is( $line->accounttype, 'RENT', 'The issue of item with issueing charge generates an accountline of the correct type' ); is( $line->branchcode, $library->id, 'AddIssuingCharge correctly sets branchcode' ); - is( $line->description, 'Rental', 'AddIssuingCharge set a hardcoded description for the accountline' ); + is( $line->description, '', 'AddIssue does not set a hardcoded description for the accountline' ); $line = $lines->next; - is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); + is( $line->accounttype, 'RENT_RENEW', 'The renewal of item with issuing charge generates an accountline of the correct type' ); is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' ); - is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); + is( $line->description, '', 'AddRenewal does not set a hardcoded description for the accountline' ); - $line = $lines->next; - is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); - is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' ); - is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); + t::lib::Mocks::mock_preference( 'RenewalLog', 1 ); + $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); + $old_log_size = Koha::ActionLogs->count( \%params_renewal ); + AddRenewal( $patron->id, $item->id, $library->id ); + $new_log_size = Koha::ActionLogs->count( \%params_renewal ); + is( $new_log_size, $old_log_size + 1, 'renew log successfully added' ); }; diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t index 66456687fe..f50638a789 100644 --- a/t/db_dependent/Circulation/Returns.t +++ b/t/db_dependent/Circulation/Returns.t @@ -277,7 +277,7 @@ subtest 'Handle ids duplication' => sub { my $issue_id = $original_checkout->issue_id; my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $issue_id }); is( $account_lines->count, 1, '1 account line should exist for this issue_id' ); - is( $account_lines->next->description, 'Rental', 'patron has been charged the rentalcharge' ); + is( $account_lines->next->accounttype, 'RENT', 'patron has been charged the rentalcharge' ); $account_lines->delete; # Create an existing entry in old_issue diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index e945876378..9abae4ac40 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -211,7 +211,7 @@ $sth->execute; my $countaccount = $sth->fetchrow_array; is ($countaccount,0,"0 accountline exists"); my $checkout = Koha::Checkouts->find( $issue_id1 ); -my $charge = C4::Circulation::AddIssuingCharge( $checkout, 10 ); +my $charge = C4::Circulation::AddIssuingCharge( $checkout, 10, 'rent' ); is( ref( $charge ), 'Koha::Account::Line', "An issuing charge has been added" ); is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' ); my $offset = Koha::Account::Offsets->find( { debit_id => $charge->id } ); -- 2.11.0