Bugzilla – Attachment 83084 Details for
Bug 19066
Add branchcode to accountlines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19066: Add tests for Koha::Account->pay
Bug-19066-Add-tests-for-KohaAccount-pay.patch (text/plain), 3.22 KB, created by
Martin Renvoize (ashimema)
on 2018-12-12 08:59:22 UTC
(
hide
)
Description:
Bug 19066: Add tests for Koha::Account->pay
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-12-12 08:59:22 UTC
Size:
3.22 KB
patch
obsolete
>From 58650c114c8de776f446cc5c5a3379acbd30815b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 8 Nov 2018 11:15:25 -0300 >Subject: [PATCH] Bug 19066: Add tests for Koha::Account->pay > >This patch adds tests for Koha::Account->pay, to make sure the >library_id param is used to set the branchcode attribute. The use of >userenv to set branchcode if library_id not passed is removed. >Responsability is left to the callers to pass library_id. > >To test: >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Account.t >=> SUCCESS: Tests pass! > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Account.pm | 1 - > t/db_dependent/Accounts.t | 2 +- > t/db_dependent/Koha/Account.t | 29 ++++++++++++++++++++++++++++- > 3 files changed, 29 insertions(+), 3 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 16211044e1..2abe9623ea 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -81,7 +81,6 @@ sub pay { > my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment'; > > my $userenv = C4::Context->userenv; >- $library_id ||= $userenv ? $userenv->{branch} : undef; > > my $patron = Koha::Patrons->find( $self->{patron_id} ); > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index b52f45817c..ae71655179 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -292,7 +292,7 @@ subtest "Koha::Account::pay tests" => sub { > is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); > $line3 = Koha::Account::Lines->find( $line3->id ); > is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); >- is( $payment->branchcode, $userenv_branchcode, 'Branchcode set correctly' ); >+ is( $payment->branchcode, undef, 'branchcode passed, then undef' ); > }; > > subtest "Koha::Account::pay particular line tests" => sub { >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 664a437b69..f069e08f1e 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -19,7 +19,8 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; >+use Test::MockModule; > > use Koha::Account; > use Koha::Account::Lines; >@@ -396,3 +397,29 @@ subtest 'reconcile_balance' => sub { > $schema->storage->txn_rollback; > }; > }; >+ >+subtest 'pay() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $account = $patron->account; >+ >+ my $context = Test::MockModule->new('C4::Context'); >+ $context->mock( 'userenv', { branch => $library->id } ); >+ >+ my $credit_1_id = $account->pay({ amount => 200 }); >+ my $credit_1 = Koha::Account::Lines->find( $credit_1_id ); >+ >+ is( $credit_1->branchcode, undef, 'No branchcode is set if library_id was not passed' ); >+ >+ my $credit_2_id = $account->pay({ amount => 150, library_id => $library->id }); >+ my $credit_2 = Koha::Account::Lines->find( $credit_2_id ); >+ >+ is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.19.2
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 19066
:
65769
|
65770
|
65771
|
67756
|
67757
|
71153
|
71154
|
71155
|
73185
|
73186
|
73187
|
73595
|
77281
|
77282
|
77283
|
78900
|
78901
|
81144
|
81145
|
81146
|
81253
|
81254
|
81255
|
81684
|
81912
|
81918
|
82047
|
82048
|
82084
|
82086
|
82087
|
82469
|
82470
|
82471
|
82473
|
82474
|
82475
|
82476
|
82477
|
82478
|
83067
|
83068
|
83069
|
83070
|
83071
|
83072
|
83073
|
83074
|
83075
|
83076
|
83077
|
83078
|
83079
|
83080
|
83081
|
83082
|
83083
|
83084
|
83275
|
83519
|
83520
|
83521
|
83522
|
83523
|
83524
|
83525
|
83526
|
83527
|
83528
|
83628