Bugzilla – Attachment 107177 Details for
Bug 20815
Add ability to choose if lost fee is refunded based on length of time item has been lost
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20815: Add unit tests for changes to AddIssue
Bug-20815-Add-unit-tests-for-changes-to-AddIssue.patch (text/plain), 8.16 KB, created by
Kyle M Hall
on 2020-07-22 12:54:51 UTC
(
hide
)
Description:
Bug 20815: Add unit tests for changes to AddIssue
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2020-07-22 12:54:51 UTC
Size:
8.16 KB
patch
obsolete
>From a2afcb8e201541f0430a3fed9c7939180e136a42 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 22 Jul 2020 08:54:26 -0400 >Subject: [PATCH] Bug 20815: Add unit tests for changes to AddIssue > >--- > t/db_dependent/Circulation.t | 198 ++++++++++++++++++++++++++++++++++- > 1 file changed, 196 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index eb7b54102e..bb2ff5f978 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 => 48; >+use Test::More tests => 49; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); > >@@ -4062,7 +4062,7 @@ subtest 'Filling a hold should cancel existing transfer' => sub { > is( Koha::Item::Transfers->search({ itemnumber => $item->itemnumber, datearrived => undef })->count, 0, "No outstanding transfers when hold is waiting"); > }; > >-subtest 'Tests for NoRefundOnLostReturnedItemsAge' => sub { >+subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { > > plan tests => 4; > >@@ -4249,6 +4249,200 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge' => sub { > }; > }; > >+subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub { >+ >+ plan tests => 4; >+ >+ t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 0); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { categorycode => $patron_category->{categorycode} } >+ } >+ ); >+ my $patron2 = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { categorycode => $patron_category->{categorycode} } >+ } >+ ); >+ >+ my $biblionumber = $builder->build_sample_biblio( >+ { >+ branchcode => $library->branchcode, >+ } >+ )->biblionumber; >+ >+ # And the circulation rule >+ Koha::CirculationRules->search->delete; >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rules => { >+ issuelength => 14, >+ lengthunit => 'days', >+ } >+ } >+ ); >+ $builder->build( >+ { >+ source => 'CirculationRule', >+ value => { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund', >+ rule_value => 1 >+ } >+ } >+ ); >+ >+ subtest 'NoRefundOnLostReturnedItemsAge = undef' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); >+ t::lib::Mocks::mock_preference( 'NoRefundOnLostReturnedItemsAge', undef ); >+ >+ my $lost_on = dt_from_string->subtract( days => 7 )->date; >+ >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->branchcode, >+ replacementprice => '42', >+ } >+ ); >+ my $issue = AddIssue( $patron->unblessed, $item->barcode ); >+ LostItem( $item->itemnumber, 'cli', 0 ); >+ $item->_result->itemlost(1); >+ $item->_result->itemlost_on( $lost_on ); >+ $item->_result->update(); >+ >+ my $a = Koha::Account::Lines->search( >+ { >+ itemnumber => $item->id, >+ borrowernumber => $patron->borrowernumber >+ } >+ )->next; >+ ok( $a, "Found accountline for lost fee" ); >+ is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); >+ $issue = AddIssue( $patron2->unblessed, $item->barcode ); >+ $a = $a->get_from_storage; >+ is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); >+ $a->delete; >+ $issue->delete; >+ }; >+ >+ subtest 'NoRefundOnLostReturnedItemsAge > length of days item has been lost' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); >+ t::lib::Mocks::mock_preference( 'NoRefundOnLostReturnedItemsAge', 7 ); >+ >+ my $lost_on = dt_from_string->subtract( days => 6 )->date; >+ >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->branchcode, >+ replacementprice => '42', >+ } >+ ); >+ my $issue = AddIssue( $patron->unblessed, $item->barcode ); >+ LostItem( $item->itemnumber, 'cli', 0 ); >+ $item->_result->itemlost(1); >+ $item->_result->itemlost_on( $lost_on ); >+ $item->_result->update(); >+ >+ my $a = Koha::Account::Lines->search( >+ { >+ itemnumber => $item->id, >+ borrowernumber => $patron->borrowernumber >+ } >+ )->next; >+ ok( $a, "Found accountline for lost fee" ); >+ is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); >+ $issue = AddIssue( $patron2->unblessed, $item->barcode ); >+ $a = $a->get_from_storage; >+ is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); >+ $a->delete; >+ }; >+ >+ subtest 'NoRefundOnLostReturnedItemsAge = length of days item has been lost' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); >+ t::lib::Mocks::mock_preference( 'NoRefundOnLostReturnedItemsAge', 7 ); >+ >+ my $lost_on = dt_from_string->subtract( days => 7 )->date; >+ >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->branchcode, >+ replacementprice => '42', >+ } >+ ); >+ my $issue = AddIssue( $patron->unblessed, $item->barcode ); >+ LostItem( $item->itemnumber, 'cli', 0 ); >+ $item->_result->itemlost(1); >+ $item->_result->itemlost_on( $lost_on ); >+ $item->_result->update(); >+ >+ my $a = Koha::Account::Lines->search( >+ { >+ itemnumber => $item->id, >+ borrowernumber => $patron->borrowernumber >+ } >+ )->next; >+ ok( $a, "Found accountline for lost fee" ); >+ is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); >+ $issue = AddIssue( $patron2->unblessed, $item->barcode ); >+ $a = $a->get_from_storage; >+ is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); >+ $a->delete; >+ }; >+ >+ subtest 'NoRefundOnLostReturnedItemsAge < length of days item has been lost' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); >+ t::lib::Mocks::mock_preference( 'NoRefundOnLostReturnedItemsAge', 7 ); >+ >+ my $lost_on = dt_from_string->subtract( days => 8 )->date; >+ >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->branchcode, >+ replacementprice => '42', >+ } >+ ); >+ my $issue = AddIssue( $patron->unblessed, $item->barcode ); >+ LostItem( $item->itemnumber, 'cli', 0 ); >+ $item->_result->itemlost(1); >+ $item->_result->itemlost_on( $lost_on ); >+ $item->_result->update(); >+ >+ my $a = Koha::Account::Lines->search( >+ { >+ itemnumber => $item->id, >+ borrowernumber => $patron->borrowernumber >+ } >+ ); >+ $a = $a->next; >+ ok( $a, "Found accountline for lost fee" ); >+ is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); >+ $issue = AddIssue( $patron2->unblessed, $item->barcode ); >+ $a = $a->get_from_storage; >+ is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); >+ $a->delete; >+ }; >+}; >+ > $schema->storage->txn_rollback; > C4::Context->clear_syspref_cache(); > $branches = Koha::Libraries->search(); >-- >2.24.1 (Apple Git-126)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20815
:
98772
|
98929
|
99038
|
105141
|
106575
|
106606
|
106607
|
106608
|
107165
| 107177