Bugzilla – Attachment 167569 Details for
Bug 28575
Add ability to choose if lost fee is refunded based on when lost fee was paid off
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28575: Add unit tests
Bug-28575-Add-unit-tests.patch (text/plain), 5.82 KB, created by
Matt Blenkinsop
on 2024-06-07 10:44:25 UTC
(
hide
)
Description:
Bug 28575: Add unit tests
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-06-07 10:44:25 UTC
Size:
5.82 KB
patch
obsolete
>From 3624cafd9fc8ab9875f61b361fc7a83758e84816 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Fri, 7 Jun 2024 10:23:38 +0000 >Subject: [PATCH] Bug 28575: Add unit tests > >prove t/db_dependent/Circulation.t >--- > t/db_dependent/Circulation.t | 154 ++++++++++++++++++++++++++++++++++- > 1 file changed, 153 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 24d5909d82..b1c9426066 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 => 74; >+use Test::More tests => 75; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -6739,6 +6739,158 @@ subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { > > }; > >+subtest 'NoRefundOnLostFinesPaidAge' => sub { >+ plan tests => 2; >+ >+ 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 $biblionumber = $builder->build_sample_biblio( >+ { >+ branchcode => $library->branchcode, >+ } >+ )->biblionumber; >+ >+ 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 => 'lostreturn', >+ rule_value => 'refund' >+ } >+ } >+ ); >+ >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->branchcode, >+ } >+ ); >+ my $lost_on = dt_from_string->subtract( days => 5 )->date; >+ my $issue = AddIssue( $patron, $item->barcode ); >+ LostItem( $item->itemnumber, 'cli', 0 ); >+ $item->_result->itemlost(1); >+ $item->_result->itemlost_on($lost_on); >+ $item->_result->update(); >+ >+ my $debit = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->id, >+ date => '1970-01-01 14:00:01', >+ amount => 5, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ debit_type_code => 'LOST', >+ itemnumber => $item->itemnumber >+ } >+ )->store(); >+ my $credit = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->id, >+ date => '1970-01-01 14:00:01', >+ amountoutstanding => 0, >+ amount => -5, >+ >+ interface => 'commandline', >+ credit_type_code => 'PAYMENT' >+ } >+ )->store(); >+ my $offset = Koha::Account::Offset->new( >+ { >+ credit_id => $credit->id, >+ debit_id => $debit->id, >+ type => 'APPLY', >+ amount => -5, >+ created_on => '1971-01-01 14:00:01' >+ } >+ )->store(); >+ >+ t::lib::Mocks::mock_preference( 'NoRefundOnLostFinesPaidAge', undef ); >+ my ( $return, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); >+ >+ is( $patron->account->balance, -5, 'Lost fine has been refunded' ); >+ >+ my $patron2 = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { categorycode => $patron_category->{categorycode} } >+ } >+ ); >+ my $item2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->branchcode, >+ } >+ ); >+ my $lost_on2 = dt_from_string->subtract( days => 5 )->date; >+ my $issue2 = AddIssue( $patron2, $item2->barcode ); >+ LostItem( $item2->itemnumber, 'cli', 0 ); >+ $item2->_result->itemlost(1); >+ $item2->_result->itemlost_on($lost_on2); >+ $item2->_result->update(); >+ >+ my $debit2 = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron2->id, >+ date => '1970-01-01 14:00:01', >+ amount => 5, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ debit_type_code => 'LOST', >+ itemnumber => $item2->itemnumber >+ } >+ )->store(); >+ my $credit2 = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron2->id, >+ date => '1970-01-01 14:00:01', >+ amount => -5, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ credit_type_code => 'PAYMENT' >+ } >+ )->store(); >+ my $offset2 = Koha::Account::Offset->new( >+ { >+ credit_id => $credit2->id, >+ debit_id => $debit2->id, >+ type => 'APPLY', >+ amount => -5, >+ created_on => '1971-01-01 14:00:01' >+ } >+ )->store(); >+ >+ t::lib::Mocks::mock_preference( 'NoRefundOnLostFinesPaidAge', 5 ); >+ my ( $return2, $messages2 ) = AddReturn( $item2->barcode, $library->branchcode, undef, dt_from_string ); >+ >+ is( >+ $patron2->account->balance, 0, >+ 'Lost fine has not been refunded as it is older than NoRefundOnLostFinesPaidAge' >+ ); >+}; >+ > > $schema->storage->txn_rollback; > C4::Context->clear_syspref_cache(); >-- >2.39.3 (Apple Git-146)
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 28575
:
167567
|
167568
|
167569
|
167621
|
167622
|
167623
|
167624
|
167627
|
167635
|
167636
|
167637
|
167638
|
168146