Bugzilla – Attachment 92767 Details for
Bug 6759
Use a different account type for account renewals than for new accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6759: (QA follow-up) Unit tests
Bug-6759-QA-follow-up-Unit-tests.patch (text/plain), 3.39 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-09-12 18:17:11 UTC
(
hide
)
Description:
Bug 6759: (QA follow-up) Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-09-12 18:17:11 UTC
Size:
3.39 KB
patch
obsolete
>From 0167f4bbab37c2b662f4f39354f152ffec846d62 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 12 Sep 2019 15:16:04 -0300 >Subject: [PATCH] Bug 6759: (QA follow-up) Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Patron.t | 84 +++++++++++++++++++++++++++++++++++- > 1 file changed, 83 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 76bbed8b84..eea40c382d 100644 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Exception; > > use Koha::Database; >@@ -72,3 +72,85 @@ subtest 'add_guarantor() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'add_enrolment_fee_if_needed() tests' => sub { >+ >+ plan tests => 2; >+ >+ subtest 'category has enrolment fee' => sub { >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object( >+ { >+ class => 'Koha::Patron::Categories', >+ value => { >+ enrolmentfee => 20 >+ } >+ } >+ ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ categorycode => $category->categorycode >+ } >+ } >+ ); >+ >+ my $enrollment_fee = $patron->add_enrolment_fee_if_needed(); >+ is( $enrollment_fee * 1, 20, 'Enrolment fee amount is correct' ); >+ my $account = $patron->account; >+ is( $patron->account->balance * 1, 20, 'Patron charged the enrolment fee' ); >+ # second enrolment fee, new >+ $enrollment_fee = $patron->add_enrolment_fee_if_needed(0); >+ # third enrolment fee, renewal >+ $enrollment_fee = $patron->add_enrolment_fee_if_needed(1); >+ is( $patron->account->balance * 1, 60, 'Patron charged the enrolment fees' ); >+ >+ my @debits = $account->outstanding_debits; >+ is( scalar @debits, 3, '3 enrolment fees' ); >+ is( $debits[0]->accounttype, 'ACCOUNT', 'Account type set correctly' ); >+ is( $debits[1]->accounttype, 'ACCOUNT', 'Account type set correctly' ); >+ is( $debits[2]->accounttype, 'ACCOUNT_RENEW', 'Account type set correctly' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'no enrolment fee' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object( >+ { >+ class => 'Koha::Patron::Categories', >+ value => { >+ enrolmentfee => 0 >+ } >+ } >+ ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ categorycode => $category->categorycode >+ } >+ } >+ ); >+ >+ my $enrollment_fee = $patron->add_enrolment_fee_if_needed(); >+ is( $enrollment_fee * 1, 0, 'No enrolment fee' ); >+ my $account = $patron->account; >+ is( $patron->account->balance, 0, 'Patron not charged anything' ); >+ >+ my @debits = $account->outstanding_debits; >+ is( scalar @debits, 0, 'no debits' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+}; >-- >2.23.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 6759
:
88614
|
88615
|
88731
|
88732
|
91533
|
91534
|
91662
|
91663
|
92765
|
92766
| 92767