Bugzilla – Attachment 92947 Details for
Bug 23355
Add a 'cashup' process to accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23355: Tests for Account::Lines summation methods
Bug-23355-Tests-for-AccountLines-summation-methods.patch (text/plain), 8.60 KB, created by
Martin Renvoize (ashimema)
on 2019-09-18 14:59:15 UTC
(
hide
)
Description:
Bug 23355: Tests for Account::Lines summation methods
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-09-18 14:59:15 UTC
Size:
8.60 KB
patch
obsolete
>From cdb7e561b33efa059a75f16479820fd211b34d0a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 22 Aug 2019 15:03:04 +0100 >Subject: [PATCH] Bug 23355: Tests for Account::Lines summation methods > >--- > t/db_dependent/Koha/Account/Lines.t | 229 +++++++++++++++++++++++++++- > 1 file changed, 228 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t >index cdc31720f5..0f87057a60 100755 >--- a/t/db_dependent/Koha/Account/Lines.t >+++ b/t/db_dependent/Koha/Account/Lines.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 4; > use Test::Exception; > > use Koha::Account; >@@ -108,5 +108,232 @@ subtest 'total_outstanding() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'total() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->total, 0, 'total returns 0 if no lines (undef case)' ); >+ >+ my $debit_1 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => 10, >+ amountoutstanding => 10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ my $debit_2 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => 10, >+ amountoutstanding => 10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->total, 20, 'total sums correctly' ); >+ >+ my $credit_1 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -10, >+ amountoutstanding => -10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->total, 10, 'total sums correctly' ); >+ >+ my $credit_2 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -10, >+ amountoutstanding => -10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->total, 0, 'total sums correctly' ); >+ >+ my $credit_3 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -100, >+ amountoutstanding => -100, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->total, -100, 'total sums correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'credits_total() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->credits_total, 0, 'credits_total returns 0 if no lines (undef case)' ); >+ >+ my $debit_1 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => 10, >+ amountoutstanding => 10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ my $debit_2 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => 10, >+ amountoutstanding => 10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->credits_total, 0, 'credits_total sums correctly' ); >+ >+ my $credit_1 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -10, >+ amountoutstanding => -10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->credits_total, -10, 'credits_total sums correctly' ); >+ >+ my $credit_2 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -10, >+ amountoutstanding => -10, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->credits_total, -20, 'credits_total sums correctly' ); >+ >+ my $credit_3 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -100, >+ amountoutstanding => -100, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->credits_total, -120, 'credits_total sums correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'debits_total() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->debits_total, 0, 'debits_total returns 0 if no lines (undef case)' ); >+ >+ my $debit_1 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => 10, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ my $debit_2 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => 10, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->debits_total, 20, 'debits_total sums correctly' ); >+ >+ my $credit_1 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -10, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->debits_total, 20, 'debits_total sums correctly' ); >+ >+ my $credit_2 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -10, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->debits_total, 20, 'debits_total sums correctly' ); >+ >+ my $credit_3 = Koha::Account::Line->new( >+ { borrowernumber => $patron->id, >+ accounttype => "OVERDUE", >+ status => "RETURNED", >+ amount => -100, >+ amountoutstanding => 0, >+ interface => 'commandline', >+ } >+ )->store; >+ >+ $lines = Koha::Account::Lines->search({ borrowernumber => $patron->id }); >+ is( $lines->debits_total, 20, 'debits_total sums correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; > > 1; >-- >2.20.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 23355
:
92941
|
92942
|
92943
|
92944
|
92945
|
92946
|
92947
|
92948
|
92949
|
92950
|
92951
|
92952
|
92953
|
97031
|
97032
|
97033
|
97034
|
97035
|
97036
|
97037
|
97038
|
97039
|
97040
|
97041
|
97043
|
97044
|
97045
|
97046
|
97047
|
97048
|
97049
|
97050
|
97051
|
97052
|
97053
|
97054
|
97077
|
97078
|
97079
|
97080
|
97081
|
97082
|
97083
|
97084
|
97085
|
97086
|
97087
|
97088
|
97089
|
97706
|
97707
|
97708
|
97709
|
97710
|
97711
|
97712
|
97713
|
97714
|
97715
|
97716
|
97784
|
97785
|
97786
|
97787
|
97788
|
97789
|
97790
|
97791
|
97792
|
97793
|
97794
|
97816
|
97817
|
97818
|
97819
|
97820
|
97821
|
97822
|
97823
|
98026
|
98027
|
98028
|
98835
|
98836
|
98837
|
98838
|
98839
|
98840
|
98841
|
98842
|
100009
|
100010
|
100011
|
100012
|
100013
|
100014
|
100015
|
100016
|
100017
|
100018
|
100019
|
100020
|
100021
|
100030
|
100090
|
101685