Bugzilla – Attachment 83047 Details for
Bug 21969
Koha::Account->outstanding_* should look for debits/credits by checking 'amount'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21969: Regression tests
Bug-21969-Regression-tests.patch (text/plain), 6.26 KB, created by
Kyle M Hall (khall)
on 2018-12-11 14:59:57 UTC
(
hide
)
Description:
Bug 21969: Regression tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-12-11 14:59:57 UTC
Size:
6.26 KB
patch
obsolete
>From 63d7c33c90195e6bcc83efcfe862d47fd43fdeab Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 6 Dec 2018 15:37:37 -0300 >Subject: [PATCH] Bug 21969: Regression tests > >This patch introduces regression tests for Koha::Account::outstanding_* >methods so they don't pick wrong lines when amountoutstanding matches >what we are looking for (i.e. negative for credits and positive for >debits). > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Account.t >=> FAIL: Tests fail because pathological account lines are wrongly >picked. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/Account.t | 40 +++++++++++++++++++++++------------ > 1 file changed, 26 insertions(+), 14 deletions(-) > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 16654f6c85..664a437b69 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -33,17 +33,17 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'outstanding_debits() tests' => sub { > >- plan tests => 12; >+ plan tests => 13; > > $schema->storage->txn_begin; > > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > > my @generated_lines; >- push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store; >- push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 2 })->store; >- push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store; >- push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store; > > my $account = $patron->account; > my $lines = $account->outstanding_debits(); >@@ -59,8 +59,8 @@ subtest 'outstanding_debits() tests' => sub { > > my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); > Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -2 })->store; >- my $just_one = Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => 3 })->store; >- Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -6 })->store; >+ my $just_one = Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => 3, amountoutstanding => 3 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -6, amountoutstanding => -6 })->store; > $lines = $patron_2->account->outstanding_debits(); > is( $lines->total_outstanding, 3, "Total if some outstanding debits and some credits is only debits" ); > is( $lines->count, 1, "With 1 outstanding debits, we get back a Lines object with 1 lines" ); >@@ -68,24 +68,30 @@ subtest 'outstanding_debits() tests' => sub { > is_deeply( $the_line->unblessed, $lines->next->unblessed, "We get back the one correct line"); > > my $patron_3 = $builder->build_object({ class => 'Koha::Patrons' }); >- Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -2 })->store; >- Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -20 })->store; >- Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -200 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -2, amountoutstanding => -2 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -20, amountoutstanding => -20 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -200, amountoutstanding => -200 })->store; > $lines = $patron_3->account->outstanding_debits(); > is( $lines->total_outstanding, 0, "Total if no outstanding debits total is 0" ); > is( $lines->count, 0, "With 0 outstanding debits, we get back a Lines object with 0 lines" ); > >- my $patron_4 = $builder->build_object({ class => 'Koha::Patrons' }); >- $lines = $patron_4->account->outstanding_debits(); >+ my $patron_4 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $account_4 = $patron_4->account; >+ $lines = $account_4->outstanding_debits(); > is( $lines->total_outstanding, 0, "Total if no outstanding debits is 0" ); > is( $lines->count, 0, "With no outstanding debits, we get back a Lines object with 0 lines" ); > >+ # create a pathological credit with amountoutstanding > 0 (BZ 14591) >+ Koha::Account::Line->new({ borrowernumber => $patron_4->id, amount => -3, amountoutstanding => 3 })->store(); >+ $lines = $account_4->outstanding_debits(); >+ is( $lines->count, 0, 'No credits are confused with debits because of the amountoutstanding value' ); >+ > $schema->storage->txn_rollback; > }; > > subtest 'outstanding_credits() tests' => sub { > >- plan tests => 7; >+ plan tests => 8; > > $schema->storage->txn_begin; > >@@ -110,10 +116,16 @@ subtest 'outstanding_credits() tests' => sub { > } > > my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); >- $lines = $patron_2->account->outstanding_credits(); >+ $account = $patron_2->account; >+ $lines = $account->outstanding_credits(); > is( $lines->total_outstanding, 0, "Total if no outstanding credits is 0" ); > is( $lines->count, 0, "With no outstanding credits, we get back a Lines object with 0 lines" ); > >+ # create a pathological debit with amountoutstanding < 0 (BZ 14591) >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => 2, amountoutstanding => -3 })->store(); >+ $lines = $account->outstanding_credits(); >+ is( $lines->count, 0, 'No debits are confused with credits because of the amountoutstanding value' ); >+ > $schema->storage->txn_rollback; > }; > >-- >2.17.2 (Apple Git-113)
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 21969
:
82939
|
82940
|
83011
|
83012
| 83047 |
83048