Bugzilla – Attachment 70343 Details for
Bug 12001
GetMemberAccountRecords slows down display of patron details and checkout pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12001: Add tests
Bug-12001-Add-tests.patch (text/plain), 7.54 KB, created by
Jonathan Druart
on 2018-01-09 14:04:55 UTC
(
hide
)
Description:
Bug 12001: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-01-09 14:04:55 UTC
Size:
7.54 KB
patch
obsolete
>From ddb6ebd598c2a18db64547e34ca8561a3b5d1c4f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 5 Jan 2018 17:46:51 -0300 >Subject: [PATCH] Bug 12001: Add tests > >Yes, we need tests to make sure we understand what is going on in this >subroutine. >The different combination of HoldsInNoissuesCharge, >RentalsInNoissuesCharge and ManInvInNoissuesCharge are tested here with >the subroutine we are going to remove (GetMemberAccountBalance). >In one of the next patches the new methods will be used to make sure we >are not modifying the calculated values (except the formatting). >--- > t/db_dependent/Accounts.t | 173 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 171 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 51c094af05..2c276c82eb 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -18,17 +18,18 @@ > > use Modern::Perl; > >-use Test::More tests => 23; >+use Test::More tests => 24; > use Test::MockModule; > use Test::Warn; > > use t::lib::TestBuilder; > use t::lib::Mocks; > >+use C4::Members; > use Koha::Account; > use Koha::Account::Lines; >-use Koha::Account::Line; > use Koha::Account::Offsets; >+use Koha::DateUtils qw( dt_from_string ); > > BEGIN { > use_ok('C4::Accounts'); >@@ -627,4 +628,172 @@ subtest "Koha::Account::chargelostitem tests" => sub { > is( $procfee->amount, "2.040000", "Processing fee if processing fee"); > }; > >+subtest "Koha::Account::non_issues_charges tests" => sub { >+ plan tests => 21; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $today = dt_from_string; >+ my $res = 3; >+ my $rent = 5; >+ my $manual = 7; >+ Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ accountno => 1, >+ date => $today, >+ description => 'a Res fee', >+ accounttype => 'Res', >+ amountoutstanding => $res, >+ } >+ )->store; >+ Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ accountno => 2, >+ date => $today, >+ description => 'a Rental fee', >+ accounttype => 'Rent', >+ amountoutstanding => $rent, >+ } >+ )->store; >+ Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ accountno => 3, >+ date => $today, >+ description => 'a Manual invoice fee', >+ accounttype => 'Copie', >+ amountoutstanding => $manual, >+ } >+ )->store; >+ Koha::AuthorisedValue->new( >+ { >+ category => 'MANUAL_INV', >+ authorised_value => 'Copie', >+ lib => 'Fee for copie', >+ } >+ )->store; >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); >+ my ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( $non_issues_charges, 0, >+ 'If 0|0|0 there should not have non issues charges' ); >+ is( $other_charges, 15, 'If 0|0|0 there should only have other charges' ); >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); >+ ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( $non_issues_charges, $manual, >+ 'If 0|0|1 Only Manual should be a non issue charge' ); >+ is( >+ $other_charges, >+ $res + $rent, >+ 'If 0|0|1 Res + Rent should be other charges' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); >+ ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( $non_issues_charges, $rent, >+ 'If 0|1|0 Only Rental should be a non issue charge' ); >+ is( >+ $other_charges, >+ $res + $manual, >+ 'If 0|1|0 Rent + Manual should be other charges' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); >+ ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( >+ $non_issues_charges, >+ $rent + $manual, >+ 'If 0|1|1 Rent + Manual should be non issues charges' >+ ); >+ is( $other_charges, $res, 'If 0|1|1 there should only have other charges' ); >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); >+ ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( $non_issues_charges, $res, >+ 'If 1|0|0 Only Res should be non issues charges' ); >+ is( >+ $other_charges, >+ $rent + $manual, >+ 'If 1|0|0 Rent + Manual should be other charges' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); >+ ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( >+ $non_issues_charges, >+ $res + $rent, >+ 'If 1|1|0 Res + Rent should be non issues charges' >+ ); >+ is( $other_charges, $manual, >+ 'If 1|1|0 Only Manual should be other charges' ); >+ >+ t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); >+ t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); >+ ( $total, $non_issues_charges, $other_charges ) = >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); >+ is( >+ $total, >+ $res + $rent + $manual, >+ 'Total charges should be Res + Rent + Manual' >+ ); >+ is( >+ $non_issues_charges, >+ $res + $rent + $manual, >+ 'If 1|1|1 Res + Rent + Manual should be non issues charges' >+ ); >+ is( $other_charges, 0, 'If 1|1|1 there should not have any other charges' ); >+}; >+ > 1; >-- >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 12001
:
70314
|
70342
|
70343
|
70344
|
70345
|
70346
|
71798
|
71799
|
71800
|
71801
|
71802
|
71852
|
71853
|
71854
|
71855
|
71856
|
71857
|
71979
|
71980
|
71981
|
71982
|
71983
|
71984
|
71985
|
71986
|
71987
|
71988
|
77066
|
77136
|
77278
|
77279