Bugzilla – Attachment 29757 Details for
Bug 11373
Add "change calculation" feature to the fine payment forms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11373 - Unit tests for Accounts.pm
Bug-11373---Unit-tests-for-Accountspm.patch (text/plain), 4.59 KB, created by
Maxime Beaulieu
on 2014-07-16 14:36:54 UTC
(
hide
)
Description:
Bug 11373 - Unit tests for Accounts.pm
Filename:
MIME Type:
Creator:
Maxime Beaulieu
Created:
2014-07-16 14:36:54 UTC
Size:
4.59 KB
patch
obsolete
>From e811f433d3b0aa5d6993784b5b8b2bacb8d9d4bf Mon Sep 17 00:00:00 2001 >From: mbeaulieu <mbeaulieu@inlibro.com> >Date: Wed, 16 Jul 2014 10:28:59 -0400 >Subject: [PATCH] Bug 11373 - Unit tests for Accounts.pm > >I added unit tests for the modified subs in C4/Accounts.pm. > makepartialpayment() > WriteOffFee() > > modified: t/db_dependent/Accounts.t >--- > t/db_dependent/Accounts.t | 79 +++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 72 insertions(+), 7 deletions(-) > mode change 100644 => 100755 t/db_dependent/Accounts.t > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >old mode 100644 >new mode 100755 >index 1c2dd5a..badf703 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -1,16 +1,81 @@ > #!/usr/bin/perl >-# >-# This Koha test module is a stub! >-# Add more tests here!!! >- > use strict; > use warnings; >- >-use Test::More tests => 1; >+use Test::More tests => 9; >+use Test::MockModule; >+use DBD::Mock; >+use C4::Accounts; > > BEGIN { >- use_ok('C4::Accounts'); >+ use_ok('C4::Accounts'); > } >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+my $FinesLogPref = C4::Context->preference("FinesLog"); >+C4::Context->set_preference("FinesLog", 0); >+# BUG 11373 - Subs to test >+#makepartialpayment($accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note) >+#WriteOffFee($borrowernumber, $accountlines_id, $itemnum, $accounttype, $amoutn, $branch, $payment_note) >+ >+# Creating an outstanding fee >+my $borrowernumber = 123456789; >+my $accountno = 1; >+my $accountlines_id = 1234; >+my $categorycode = 'ZYX'; >+my $branchcode = 'XYZ'; >+ >+my $insertcategory="INSERT INTO categories (categorycode, description, enrolmentperiod, upperagelimit, dateofbirthrequired,". >+ "finetype, bulk, enrolmentfee, overduenoticerequired, issuelimit, reservefee, category_type)". >+ "VALUES (?,'Placeholder',99,999,18,NULL,NULL,'0.000000',0,NULL,'0.000000',?)"; >+ >+my $insertbranch="INSERT INTO branches ( branchcode, branchname, branchaddress1) VALUES (?,'Placeholder','Placeholder')"; >+ >+my $insertborrower='insert into borrowers (borrowernumber, categorycode, branchcode, cardnumber,'. >+ 'surname, dateenrolled, dateexpiry, flags, userid, password, privacy, email)'. >+ 'values (?, ?, ?, "123456789", "UnitTester", "2001-01-01", "2099-01-01", 1, "userid", "pa$$word", 1, "ph@pholder.com")'; >+ >+my $insertfee = 'INSERT INTO accountlines (accountlines_id, borrowernumber, accountno, date, amount, amountoutstanding) ' >+ . ' VALUES (?, ?, ?, NOW(), ?, ?)'; >+ >+print "\nTesting makepartialpayment\nCreating an outstanding fee of \$5 for testing purposes\n"; >+$dbh->do($insertbranch, undef, $branchcode); >+$dbh->do($insertcategory, undef, $categorycode, 'S'); >+$dbh->do($insertborrower, undef, $borrowernumber, $categorycode, $branchcode); >+$dbh->do($insertfee, undef, $accountlines_id, $borrowernumber, $accountno, 0, 5); >+ >+print "Making a partial payment of \$3\n"; >+makepartialpayment($accountlines_id, $borrowernumber, $accountno, 3, 'user', $branchcode, 'Testing'); >+ >+my $statement = $dbh->prepare('SELECT * from accountlines where borrowernumber = ?'); >+$statement->execute($borrowernumber); >+my $result = $statement->fetchall_hashref('accountno'); >+ >+is(scalar(keys(%$result)), 2, 'A new entry is added in accountlines'); >+is($result->{2}->{'accounttype'}, 'Pay', 'The new entry is a payment'); >+is($result->{2}->{'amount'}*1, -3, 'Amount paid is -3'); >+is($result->{1}->{'amountoutstanding'}*1, 2, 'Amount outstanding is 2'); >+ >+$dbh->rollback; # Making sure the two test sets are independant. >+ >+print "\nTesting WriteOffFee\nCreating an outstanding fee of \$10 for testing purposes\n"; >+$dbh->do($insertbranch, undef, $branchcode); >+$dbh->do($insertcategory, undef, $categorycode, 'S'); >+$dbh->do($insertborrower, undef, $borrowernumber, $categorycode, $branchcode); >+$dbh->do($insertfee, undef, $accountlines_id, $borrowernumber, $accountno, 0, 10); >+ >+print "Writing off the fee (10)\n"; >+WriteOffFee($borrowernumber, $accountlines_id, undef, 'wut', 10, $branchcode, 'Testing'); > >+$statement = $dbh->prepare('SELECT * from accountlines where borrowernumber = ?'); >+$statement->execute($borrowernumber); >+$result = $statement->fetchall_hashref('accountno'); > >+is(scalar(keys(%$result)), 2, 'A new entry is added in accountlines'); >+is($result->{2}->{'accounttype'}, 'W', 'The new entry is a writeoff'); >+is($result->{2}->{'amount'}*1, -10, 'Amount paid is -10'); >+is($result->{1}->{'amountoutstanding'}*1, 0, 'Amount outstanding is 0'); > >+$dbh->rollback; >+C4::Context->set_preference("FinesLog", $FinesLogPref); >-- >1.7.9.5
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 11373
:
23382
|
26103
|
26108
|
29757
|
29938
|
36875
|
36876
|
36877
|
60528
|
60529
|
61233
|
61234
|
67348
|
68296
|
70043
|
71975
|
71976
|
77584
|
77585
|
79122
|
79171
|
79188
|
79507
|
79509
|
79529
|
79530
|
79538
|
79549
|
79759
|
79944
|
79951
|
80414
|
80986
|
82420
|
82797
|
83804
|
83812
|
83813
|
84653
|
84654