Bugzilla – Attachment 109937 Details for
Bug 19382
Add ability to block guarantees based on fees owed by guarantor and other guarantees
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19382: (follow-up) Alternate tests
Bug-19382-follow-up-Alternate-tests.patch (text/plain), 36.32 KB, created by
Kyle M Hall (khall)
on 2020-09-11 12:30:21 UTC
(
hide
)
Description:
Bug 19382: (follow-up) Alternate tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-09-11 12:30:21 UTC
Size:
36.32 KB
patch
obsolete
>From 1255bc25a5f440402e6c47ac48ccf4429e772f77 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 10 Sep 2020 11:04:18 +0100 >Subject: [PATCH] Bug 19382: (follow-up) Alternate tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/Patron.t | 383 ++++++++++------------------------- > 1 file changed, 104 insertions(+), 279 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index ae15b3a0f2..dbdbf73c82 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -85,10 +85,10 @@ subtest 'relationships_debt() tests' => sub { > > t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' ); > >- my $parent_1 = $builder->build_object({ class => 'Koha::Patrons' }); >- my $parent_2 = $builder->build_object({ class => 'Koha::Patrons' }); >- my $child_1 = $builder->build_object({ class => 'Koha::Patrons' }); >- my $child_2 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $parent_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 1" } }); >+ my $parent_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 2" } }); >+ my $child_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Child 1" } }); >+ my $child_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Child 2" } }); > > $child_1->add_guarantor({ guarantor_id => $parent_1->borrowernumber, relationship => 'parent' }); > $child_1->add_guarantor({ guarantor_id => $parent_2->borrowernumber, relationship => 'parent' }); >@@ -97,285 +97,110 @@ subtest 'relationships_debt() tests' => sub { > > is( $child_1->guarantor_relationships->guarantors->count, 2, 'Child 1 has correct number of guarantors' ); > is( $child_2->guarantor_relationships->guarantors->count, 2, 'Child 2 has correct number of guarantors' ); >- is( $parent_1->guarantee_relationships->guarantees->count, 2, 'Parent 1 has correct number of guarantors' ); >- is( $parent_2->guarantee_relationships->guarantees->count, 2, 'Parent 2 has correct number of guarantors' ); >- >- # 3 params, count from 0 to 6 in binary ( 3 places ) to get the set of switches, then do that 4 times, one for each parent and child >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- $child_2->account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); >- is( $child_2->account->non_issues_charges, 10, 'Child 2 owes correct amount' ); >- >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- $parent_1->account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); >- is( $parent_1->account->non_issues_charges, 10, 'Parent 1 owes correct amount' ); >- >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- $parent_2->account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); >- is( $parent_2->account->non_issues_charges, 10, 'Parent 2 owes correct amount' ); >- >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 30, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 30, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 30, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 30, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 30, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- $child_1->account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); >- is( $child_1->account->non_issues_charges, 10, 'Child 1 owes correct amount' ); >- >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 30, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 40, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 30, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 30, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 40, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 20, 'Family debt is correct' ); >- is( $parent_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 30, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 30, 'Family debt is correct' ); >- is( $child_1->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 40, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_1->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 0 }), 10, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 0, include_this_patron => 1 }), 20, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 0 }), 30, 'Family debt is correct' ); >- is( $child_2->relationships_debt({ only_this_guarantor => 0, include_guarantors => 1, include_this_patron => 1 }), 40, 'Family debt is correct' ); >- >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 0, include_this_patron => 1 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 0 }), 0, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >- throws_ok { >- is( $child_2->relationships_debt({ only_this_guarantor => 1, include_guarantors => 1, include_this_patron => 1 }), 10, 'Family debt is correct' ); >- } 'Koha::Exceptions::BadParameter', 'Exception is thrown as patron is not a guarantor'; >+ is( $parent_1->guarantee_relationships->guarantees->count, 2, 'Parent 1 has correct number of guarantees' ); >+ is( $parent_2->guarantee_relationships->guarantees->count, 2, 'Parent 2 has correct number of guarantees' ); >+ >+ my $patrons = [ $parent_1, $parent_2, $child_1, $child_2 ]; >+ >+ # First test: No debt >+ my ($parent1_debt, $parent2_debt, $child1_debt, $child2_debt) = (0,0,0,0); >+ _test_combinations($patrons, $parent1_debt,$parent2_debt,$child1_debt,$child2_debt); >+ >+ # Add debt to child_2 >+ $child2_debt = 2; >+ $child_2->account->add_debit({ type => 'ACCOUNT', amount => $child2_debt, interface => 'commandline' }); >+ is( $child_2->account->non_issues_charges, $child2_debt, 'Debt added to Child 2' ); >+ _test_combinations($patrons, $parent1_debt,$parent2_debt,$child1_debt,$child2_debt); >+ >+ $parent1_debt = 3; >+ $parent_1->account->add_debit({ type => 'ACCOUNT', amount => $parent1_debt, interface => 'commandline' }); >+ is( $parent_1->account->non_issues_charges, $parent1_debt, 'Debt added to Parent 1' ); >+ _test_combinations($patrons, $parent1_debt,$parent2_debt,$child1_debt,$child2_debt); >+ >+ $parent2_debt = 5; >+ $parent_2->account->add_debit({ type => 'ACCOUNT', amount => $parent2_debt, interface => 'commandline' }); >+ is( $parent_2->account->non_issues_charges, $parent2_debt, 'Parent 2 owes correct amount' ); >+ _test_combinations($patrons, $parent1_debt,$parent2_debt,$child1_debt,$child2_debt); >+ >+ $child1_debt = 7; >+ $child_1->account->add_debit({ type => 'ACCOUNT', amount => $child1_debt, interface => 'commandline' }); >+ is( $child_1->account->non_issues_charges, $child1_debt, 'Child 1 owes correct amount' ); >+ _test_combinations($patrons, $parent1_debt,$parent2_debt,$child1_debt,$child2_debt); > > $schema->storage->txn_rollback; > }; > >+sub _test_combinations { >+ my ( $patrons, $parent1_debt, $parent2_debt, $child1_debt, $child2_debt ) = @_; >+ >+ # Options >+ # P1 => P1 + C1 + C2 ( - P1 ) ( + P2 ) >+ # P2 => P2 + C1 + C2 ( - P2 ) ( + P1 ) >+ # C1 => P1 + P2 + C1 + C2 ( - C1 ) >+ # C2 => P1 + P2 + C1 + C2 ( - C2 ) >+ >+# 3 params, count from 0 to 6 in binary ( 3 places ) to get the set of switches, then do that 4 times, one for each parent and child >+ for my $i ( 0 .. 7 ) { >+ my ( $only_this_guarantor, $include_guarantors, $include_this_patron ) >+ = split '', sprintf( "%03b", $i ); >+ for my $patron ( @$patrons ) { >+ if ( $only_this_guarantor >+ && !$patron->guarantee_relationships->count ) >+ { >+ throws_ok { >+ $patron->relationships_debt( >+ { >+ only_this_guarantor => $only_this_guarantor, >+ include_guarantors => $include_guarantors, >+ include_this_patron => $include_this_patron >+ } >+ ); >+ } >+ 'Koha::Exceptions::BadParameter', >+ 'Exception is thrown as patron is not a guarantor'; >+ >+ } >+ else { >+ >+ my $debt = 0; >+ if ( $patron->firstname eq 'Parent 1' ) { >+ $debt += $parent1_debt if ($include_this_patron && $include_guarantors); >+ $debt += $child1_debt + $child2_debt; >+ $debt += $parent2_debt unless ($only_this_guarantor || !$include_guarantors); >+ } >+ elsif ( $patron->firstname eq 'Parent 2' ) { >+ $debt += $parent2_debt if ($include_this_patron & $include_guarantors); >+ $debt += $child1_debt + $child2_debt; >+ $debt += $parent1_debt unless ($only_this_guarantor || !$include_guarantors); >+ } >+ elsif ( $patron->firstname eq 'Child 1' ) { >+ $debt += $child1_debt if ($include_this_patron); >+ $debt += $child2_debt; >+ $debt += $parent1_debt + $parent2_debt if ($include_guarantors); >+ } >+ else { >+ $debt += $child2_debt if ($include_this_patron); >+ $debt += $child1_debt; >+ $debt += $parent1_debt + $parent2_debt if ($include_guarantors); >+ } >+ >+ is( >+ $patron->relationships_debt( >+ { >+ only_this_guarantor => $only_this_guarantor, >+ include_guarantors => $include_guarantors, >+ include_this_patron => $include_this_patron >+ } >+ ), >+ $debt, >+ $patron->firstname >+ . " debt of $debt calculated correctly for ( only_this_guarantor: $only_this_guarantor, include_guarantors: $include_guarantors, include_this_patron: $include_this_patron)" >+ ); >+ } >+ } >+ } >+} >+ > subtest 'add_enrolment_fee_if_needed() tests' => sub { > > plan tests => 2; >-- >2.24.1 (Apple Git-126)
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 19382
:
97234
|
97235
|
97303
|
99196
|
102090
|
106534
|
107344
|
109210
|
109211
|
109349
|
109357
|
109634
|
109635
|
109636
|
109841
|
109937
|
111570
|
111571
|
111572
|
111573
|
111574
|
111609