Bugzilla – Attachment 53784 Details for
Bug 15896
Use Koha::Account::pay internally for makepayment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bug 15896 - A few tests for Koha::Account
bug-15896---A-few-tests-for-KohaAccount.patch (text/plain), 3.38 KB, created by
Josef Moravec
on 2016-07-28 15:59:36 UTC
(
hide
)
Description:
bug 15896 - A few tests for Koha::Account
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2016-07-28 15:59:36 UTC
Size:
3.38 KB
patch
obsolete
>From 87545c5d18dcbce11fa1868ec4e9453cc22c114a Mon Sep 17 00:00:00 2001 >From: Florent Mara <florent.mara@gmail.com> >Date: Tue, 31 May 2016 16:32:56 +1200 >Subject: [PATCH] bug 15896 - A few tests for Koha::Account > >--- > t/db_dependent/Koha/Account.t | 89 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 89 insertions(+) > create mode 100644 t/db_dependent/Koha/Account.t > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >new file mode 100644 >index 0000000..47a3c44 >--- /dev/null >+++ b/t/db_dependent/Koha/Account.t >@@ -0,0 +1,89 @@ >+#!/usr/bin/perl >+ >+# Copyright 2015 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Test::More tests => 5; >+ >+# use t::lib::Mocks; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+my $builder = t::lib::TestBuilder->new(); >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+# ########## Tests start here ############################# >+# Given ... we can use the module >+BEGIN { use_ok('Koha::Account'); } >+ >+subtest 'test_methods' => sub { >+ plan tests => 1; >+ >+ # Given ... we can reach the method(s) >+ my @methods = ( >+ 'pay', >+ ); >+ can_ok('Koha::Account', @methods); >+}; >+ >+# Given ... a random patron_id, a Koha::Account object can be created >+my $patron_id_0 = 654321; >+ >+# When ... >+my $koha_account_0 = Koha::Account->new( { patron_id => $patron_id_0 } ); >+ >+# Then ... >+isa_ok($koha_account_0, 'Koha::Account'); >+is($koha_account_0->{patron_id}, $patron_id_0, 'Got the expected patron_id value from calling Koha:;Account->new()'); >+ >+# FIXME pay() method does not deal with absence of parameters and die on >+# Use of uninitialized value $amount in subtraction (-) at /var/koha/Koha/Koha/Account.pm line 175 >+# ... >+# Given ... calling on pay() with no params - just for fun. >+# my $params_1 = {}; >+ >+# When ... Then ... >+# my $payment_id_1 = $koha_account_0->pay($params_1); >+# is($payment_id_1, undef, 'Got the expected undef payment id from Koha account pay with no params'); >+ >+# Given ... an amount parameter and a borrower number >+my $amount_2 = 90; >+my $params_2 = { amount => $amount_2, }; >+ >+$dbh->do("INSERT INTO borrowers(borrowernumber, surname, address, city, branchcode, categorycode, userid) VALUES ('.$patron_id_0.','Washington','address','city', 'IPT', 'HB', 'userid')"); >+ >+# When ... >+my $payment_id_2 = $koha_account_0->pay($params_2); >+ >+# Then ... >+ok($payment_id_2, 'Got some data back from Koha account pay with an amount'); >+ >+# my $sth_2 = $dbh->prepare('SELECT * FROM accountlines WHERE borrowernumber = ?'); >+# my $acc_line = $sth_2->execute($patron_id_0); >+# my $result_2 = $sth_2->fetchrow(); >+ >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.1.4
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 15896
:
48332
|
51920
|
52139
|
53314
|
53782
|
53783
|
53784
|
53785
|
53786
|
55924
|
55925
|
57175
|
57176
|
57177
|
57178
|
57182
|
57183
|
57184
|
57185
|
57186
|
57187
|
57188
|
57189
|
57190
|
57191
|
57192
|
57193