Bugzilla – Attachment 119639 Details for
Bug 25508
Confusing renewal message when paying accruing fine with RenewAccruingItemWhenPaid turned off
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25508: Add Unit Tests
Bug-25508-Add-Unit-Tests.patch (text/plain), 3.02 KB, created by
Nick Clemens (kidclamp)
on 2021-04-15 15:30:43 UTC
(
hide
)
Description:
Bug 25508: Add Unit Tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-04-15 15:30:43 UTC
Size:
3.02 KB
patch
obsolete
>From d0792dd7387fd831adaecbbbea3009549d26168d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 6 Apr 2021 08:48:38 +0100 >Subject: [PATCH] Bug 25508: Add Unit Tests > >Enhance the unit tests to check for the return values of >Koha::Account->pay. > >Test plan >1/ Apply just this patch >2/ Run t/db_dependent/Koha/Account.t and watch it fail >3/ Apply the rest of the patch series >4/ Run t/db_dependent/Koha/Account.t and watch it pass >5/ Signoff > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Account.t | 35 +++++++++++++++++++++++++++++++++-- > 1 file changed, 33 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 90ffc351cf..81869447ad 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -924,7 +924,7 @@ subtest 'pay() handles lost items when paying by amount ( not specifying the los > > subtest 'pay() renews items when appropriate' => sub { > >- plan tests => 1; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -975,7 +975,7 @@ subtest 'pay() renews items when appropriate' => sub { > my $module = Test::MockModule->new('C4::Circulation'); > $module->mock('AddRenewal', sub { $called = 1; }); > $module->mock('CanBookBeRenewed', sub { return 1; }); >- $account->pay( >+ my $result = $account->pay( > { > amount => '1', > library_id => $library->id, >@@ -983,6 +983,37 @@ subtest 'pay() renews items when appropriate' => sub { > ); > > is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' ); >+ is(ref($result->{renew_result}), 'ARRAY', "Pay result contains 'renew_result' ARRAY" ); >+ is( scalar @{$result->{renew_result}}, 1, "renew_result contains one renewal result" ); >+ is( $result->{renew_result}->[0]->{itemnumber}, $item->id, "renew_result contains itemnumber of renewed item" ); >+ >+ # Reset test by adding a new overdue >+ Koha::Account::Line->new( >+ { >+ issue_id => $checkout->id, >+ borrowernumber => $patron->id, >+ itemnumber => $item->id, >+ date => \'NOW()', >+ debit_type_code => 'OVERDUE', >+ status => 'UNRETURNED', >+ interface => 'cli', >+ amount => '1', >+ amountoutstanding => '1', >+ } >+ )->store(); >+ $called = 0; >+ >+ t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 ); >+ $result = $account->pay( >+ { >+ amount => '1', >+ library_id => $library->id, >+ } >+ ); >+ >+ is( $called, 0, 'C4::Circulation::AddRenew NOT called when RenewAccruingItemWhenPaid disabled' ); >+ is(ref($result->{renew_result}), 'ARRAY', "Pay result contains 'renew_result' ARRAY" ); >+ is( scalar @{$result->{renew_result}}, 0, "renew_result contains no renewal results" ); > > $schema->storage->txn_rollback; > }; >-- >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 25508
:
118765
|
118776
|
118777
|
118778
|
119191
|
119192
|
119213
|
119214
| 119639 |
119640
|
119641
|
119702
|
146001
|
146002
|
146003
|
146004