Bugzilla – Attachment 119676 Details for
Bug 27927
longoverdue cronjob renews items before marking lost when both RenewAccruingItemWhenPaid and WhenLostForgiveFine are enabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27927: Add Unit Tests
Bug-27927-Add-Unit-Tests.patch (text/plain), 4.09 KB, created by
Nick Clemens (kidclamp)
on 2021-04-15 18:44:16 UTC
(
hide
)
Description:
Bug 27927: Add Unit Tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-04-15 18:44:16 UTC
Size:
4.09 KB
patch
obsolete
>From 350b42b283189dd663bd7970f43573129a235c36 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 6 Apr 2021 11:19:04 +0100 >Subject: [PATCH] Bug 27927: Add Unit Tests > >Add a unit test to check that 'FORGIVEN' credits do not prompt an >auto-renewal with `RenewAccruingItemWhenPaid` enabled. > >Test plan >1/ Apply the test patch >2/ Run t/db_dependent/Koha/Account/Line.t and confirm it fails >3/ Apply subsequent patch >4/ Re-run the test and confirm it passes > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Account/Line.t | 40 ++++++++++++++++++++++++++++++++------ > 1 file changed, 34 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t >index d112b31906..da40474a9b 100755 >--- a/t/db_dependent/Koha/Account/Line.t >+++ b/t/db_dependent/Koha/Account/Line.t >@@ -175,7 +175,7 @@ subtest 'is_credit() and is_debit() tests' => sub { > > subtest 'apply() tests' => sub { > >- plan tests => 25; >+ plan tests => 26; > > $schema->storage->txn_begin; > >@@ -327,10 +327,35 @@ subtest 'apply() tests' => sub { > my $module = Test::MockModule->new('C4::Circulation'); > $module->mock('AddRenewal', sub { $called = 1; }); > $module->mock('CanBookBeRenewed', sub { return 1; }); >- my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' }); >+ my $credit_forgive = $account->add_credit( >+ { >+ amount => 1, >+ user_id => $patron->id, >+ interface => 'cli', >+ type => 'FORGIVEN' >+ } >+ ); > my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list; >- $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } ); >+ $credit_forgive->apply( { debits => $debits_renew, offset_type => 'Forgiven' } ); >+ is( $called, 0, 'C4::Circulation::AddRenew NOT called when RenewAccruingItemWhenPaid enabled but credit type is "FORGIVEN"' ); > >+ $accountline = Koha::Account::Line->new( >+ { >+ issue_id => $checkout->id, >+ borrowernumber => $patron->id, >+ itemnumber => $item->id, >+ branchcode => $library->id, >+ date => \'NOW()', >+ debit_type_code => 'OVERDUE', >+ status => 'UNRETURNED', >+ interface => 'cli', >+ amount => '1', >+ amountoutstanding => '1', >+ } >+ )->store(); >+ my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' }); >+ $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list; >+ $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } ); > is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' ); > > $schema->storage->txn_rollback; >@@ -387,7 +412,7 @@ subtest 'Keep account info when related patron, staff, item or cash_register is > > subtest 'Renewal related tests' => sub { > >- plan tests => 7; >+ plan tests => 8; > > $schema->storage->txn_begin; > >@@ -428,10 +453,13 @@ subtest 'Renewal related tests' => sub { > > > t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 ); >- is ($line->renew_item, undef, 'Attempt to renew fails when syspref is not set'); >+ is ($line->renew_item({ interface => 'intranet' }), undef, 'Attempt to renew fails when syspref is not set'); > t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 ); >+ t::lib::Mocks::mock_preference( 'RenewAccruingItemInOpac', 0 ); >+ is ($line->renew_item({ interface => 'opac' }), undef, 'Attempt to renew fails when syspref is not set - OPAC'); >+ t::lib::Mocks::mock_preference( 'RenewAccruingItemInOpac', 1 ); > is_deeply( >- $line->renew_item, >+ $line->renew_item({ interface => 'intranet' }), > { > itemnumber => $item->itemnumber, > error => 'too_many', >-- >2.11.0
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 27927
:
118766
|
118781
|
119193
|
119194
|
119235
|
119236
| 119676 |
119677