Bugzilla – Attachment 82285 Details for
Bug 21788
C4::Circulation::ProcessOfflinePayment should pass library_id to ->pay
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21788: Unit tests
Bug-21788-Unit-tests.patch (text/plain), 3.00 KB, created by
Kyle M Hall (khall)
on 2018-11-13 15:00:19 UTC
(
hide
)
Description:
Bug 21788: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-11-13 15:00:19 UTC
Size:
3.00 KB
patch
obsolete
>From b09dee8354a04e4287413129f23f49c3d429f6eb Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 8 Nov 2018 12:31:59 -0300 >Subject: [PATCH] Bug 21788: Unit tests > >This patch refactors the tests related to ProcessOfflinePayment and adds >checks for setting branchcode on the account line. > >To test: >- Run: > $ kshell > k$ prove t/db_dependent/Circulation.t >=> FAIL: branchcode is not set > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 42 ++++++++++++++++++++---------------- > 1 file changed, 24 insertions(+), 18 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 91cf0c9945..e6b9b99681 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 120; >+use Test::More tests => 121; > use Test::MockModule; > > use Data::Dumper; >@@ -208,23 +208,6 @@ $dbh->do( > .10, 1 > ); > >-# Test C4::Circulation::ProcessOfflinePayment >-my $sth = C4::Context->dbh->prepare("SELECT COUNT(*) FROM accountlines WHERE amount = '-123.45' AND accounttype = 'Pay'"); >-$sth->execute(); >-my ( $original_count ) = $sth->fetchrow_array(); >- >-C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', ?, ? )", undef, $patron_category->{categorycode}, $library2->{branchcode} ); >- >-C4::Circulation::ProcessOfflinePayment({ cardnumber => '99999999999', amount => '123.45' }); >- >-$sth->execute(); >-my ( $new_count ) = $sth->fetchrow_array(); >- >-ok( $new_count == $original_count + 1, 'ProcessOfflinePayment makes payment correctly' ); >- >-C4::Context->dbh->do("DELETE FROM accountlines WHERE borrowernumber IN ( SELECT borrowernumber FROM borrowers WHERE cardnumber = '99999999999' )"); >-C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'"); >-C4::Context->dbh->do("DELETE FROM accountlines"); > { > # CanBookBeRenewed tests > C4::Context->set_preference('ItemsDeniedRenewal',''); >@@ -2835,6 +2818,29 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'ProcessOfflinePayment() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $amount = 123; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $result = C4::Circulation::ProcessOfflinePayment({ cardnumber => $patron->cardnumber, amount => $amount, branchcode => $library->id }); >+ >+ is( $result, 'Success.', 'The right string is returned' ); >+ >+ my $lines = $patron->account->lines; >+ is( $lines->count, 1, 'line created correctly'); >+ >+ my $line = $lines->next; >+ is( $line->amount+0, $amount * -1, 'amount picked from params' ); >+ is( $line->branchcode, $library->id, 'branchcode set correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; > > sub set_userenv { > my ( $library ) = @_; >-- >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 21788
:
82094
|
82095
|
82285
|
82286
|
83721
|
83722