Bugzilla – Attachment 145194 Details for
Bug 32450
Make it possible to exclude debit types from charges counted for circulation restriction (noissuecharge)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32450: Unit tests updated
Bug-32450-Unit-tests-updated.patch (text/plain), 7.46 KB, created by
Matt Blenkinsop
on 2023-01-10 16:03:45 UTC
(
hide
)
Description:
Bug 32450: Unit tests updated
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2023-01-10 16:03:45 UTC
Size:
7.46 KB
patch
obsolete
>From 24948bda7a6b9e290897fe6013bb646a1d791072 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Tue, 10 Jan 2023 16:01:57 +0000 >Subject: [PATCH] Bug 32450: Unit tests updated > >Unit tests for the non_issues_charges function have been updated to remove the system preferences and test based on the new database flags > >Test plan: >1) Apply all patches >2) In the kshell, run prove -v t/db_dependent/Accounts.t >3) All tests should pass >--- > t/db_dependent/Accounts.t | 139 ++++++++------------------------------ > 1 file changed, 30 insertions(+), 109 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index b35c659dc0a..7b8fbcf3bd7 100755 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -764,7 +764,7 @@ subtest "C4::Accounts::chargelostitem tests" => sub { > }; > > subtest "Koha::Account::non_issues_charges tests" => sub { >- plan tests => 21; >+ plan tests => 6; > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $account = $patron->account; >@@ -772,6 +772,7 @@ subtest "Koha::Account::non_issues_charges tests" => sub { > my $res = 3; > my $rent = 5; > my $manual = 7; >+ my $print = 4; > $account->add_debit( > { > description => 'a Res fee', >@@ -805,10 +806,6 @@ subtest "Koha::Account::non_issues_charges tests" => sub { > } > )->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 ) = ( $account->balance, $account->non_issues_charges ); > my $other_charges = $total - $non_issues_charges; > is( >@@ -816,115 +813,39 @@ subtest "Koha::Account::non_issues_charges tests" => sub { > $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 ) = ( $account->balance, $account->non_issues_charges ); >- $other_charges = $total - $non_issues_charges; >- 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' >- ); >+ is( $non_issues_charges, 15, >+ 'All types should count towards the non issue charge' ); >+ is( $other_charges, 0, 'There shouldn\'t be any non-included 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 ) = ( $account->balance, $account->non_issues_charges ); >- $other_charges = $total - $non_issues_charges; >- 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 ) = ( $account->balance, $account->non_issues_charges ); >- $other_charges = $total - $non_issues_charges; >- 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' ); >+ Koha::Account::DebitTypes->find_or_create( >+ { >+ code => 'Print', >+ description => 'Charge for using the printer', >+ is_system => 0, >+ restricts_checkouts => 0 >+ } >+ )->store; >+ Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ description => 'Non-restricting fee', >+ debit_type_code => 'Print', >+ amountoutstanding => $print, >+ interface => 'commandline' >+ } >+ )->store; > >- 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 ) = ( $account->balance, $account->non_issues_charges ); >- $other_charges = $total - $non_issues_charges; >- 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' ); >+ my ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); >+ my $other_charges = $total - $non_issues_charges; > is( >- $other_charges, >- $rent + $manual, >- 'If 1|0|0 Rent + Manual should be other charges' >+ $account->balance, >+ $res + $rent + $manual + $print, >+ 'Total charges should be Res + Rent + Manual + Print' > ); >+ is( $non_issues_charges, 15, >+ 'All types except Print should count towards the non issue charge' ); >+ is( $other_charges, 4, 'There should be non-included charges for Print' ); > >- 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 ) = ( $account->balance, $account->non_issues_charges ); >- $other_charges = $total - $non_issues_charges; >- 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 ) = ( $account->balance, $account->non_issues_charges ); >- $other_charges = $total - $non_issues_charges; >- 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' ); > }; > > subtest "Koha::Account::non_issues_charges tests" => sub { >-- >2.37.1 (Apple Git-137.1)
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 32450
:
145080
|
145081
|
145127
|
145128
|
145171
|
145172
|
145189
|
145190
|
145191
|
145194
|
145198
|
147563
|
149653
|
149654
|
149655
|
149656
|
149657
|
149658
|
149659
|
149660
|
149858
|
149859
|
149872
|
149873
|
149874
|
149875
|
149876
|
149877
|
149878
|
149879
|
149880
|
149881
|
149882