Bugzilla – Attachment 43686 Details for
Bug 9129
Add the ability to set the maximum fine for an item to its replacement price
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9129 [QA Followup] - Add unit tests
Bug-9129-QA-Followup---Add-unit-tests.patch (text/plain), 4.27 KB, created by
Kyle M Hall (khall)
on 2015-10-21 11:19:03 UTC
(
hide
)
Description:
Bug 9129 [QA Followup] - Add unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-10-21 11:19:03 UTC
Size:
4.27 KB
patch
obsolete
>From 5b498ca767af8ccd7c453995cc7246dafb275438 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 21 Oct 2015 07:18:16 -0400 >Subject: [PATCH] Bug 9129 [QA Followup] - Add unit tests > >--- > t/db_dependent/Circulation/CalcFine.t | 146 +++++++++++++++++++++++++++++++++ > 1 files changed, 146 insertions(+), 0 deletions(-) > create mode 100644 t/db_dependent/Circulation/CalcFine.t > >diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t >new file mode 100644 >index 0000000..d5ab276 >--- /dev/null >+++ b/t/db_dependent/Circulation/CalcFine.t >@@ -0,0 +1,146 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+ >+use C4::Context; >+use C4::Overdues; >+ >+use Koha::DateUtils qw( dt_from_string ); >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+our $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM issues|); >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+my $branch = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $category = $builder->build( >+ { >+ source => 'Category', >+ } >+); >+ >+my $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ categorycode => $category->{categorycode}, >+ branchcode => $branch->{branchcode}, >+ }, >+ } >+); >+ >+my $biblio = $builder->build( >+ { >+ source => 'Biblio', >+ value => { >+ branchcode => $branch->{branchcode}, >+ }, >+ } >+); >+ >+my $item = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ homebranch => $branch->{branchcode}, >+ holdingbranch => $branch->{branchcode}, >+ replacementprice => '5.00', >+ }, >+ } >+); >+ >+subtest 'Test basic functionality' => sub { >+ plan tests => 1; >+ my $issuingrule = $builder->build( >+ { >+ source => 'Issuingrule', >+ value => { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ fine => '1.00', >+ lengthunit => 'days', >+ finedays => 0, >+ firstremind => 0, >+ chargeperiod => 1, >+ overduefinescap => undef, >+ cap_fine_to_replacement_price => 0, >+ }, >+ } >+ ); >+ >+ my $start_dt = DateTime->new( >+ year => 2000, >+ month => 01, >+ day => 01, >+ ); >+ >+ my $end_dt = DateTime->new( >+ year => 2000, >+ month => 01, >+ day => 30, >+ ); >+ >+ my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ >+ is( $amount, 29, 'Amount is calculated correctly' ); >+ >+ teardown(); >+}; >+ >+subtest 'Test cap_fine_to_replacement_price' => sub { >+ plan tests => 1; >+ my $issuingrule = $builder->build( >+ { >+ source => 'Issuingrule', >+ value => { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ fine => '1.00', >+ lengthunit => 'days', >+ finedays => 0, >+ firstremind => 0, >+ chargeperiod => 1, >+ overduefinescap => undef, >+ cap_fine_to_replacement_price => 1, >+ }, >+ } >+ ); >+ >+ my $start_dt = DateTime->new( >+ year => 2000, >+ month => 01, >+ day => 01, >+ ); >+ >+ my $end_dt = DateTime->new( >+ year => 2000, >+ month => 01, >+ day => 30, >+ ); >+ >+ my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ >+ is( $amount, '5.00', 'Amount is calculated correctly' ); >+ >+ teardown(); >+}; >+ >+sub teardown { >+ $dbh->do(q|DELETE FROM issuingrules|); >+} >-- >1.7.2.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 9129
:
13612
|
13614
|
13615
|
13616
|
14553
|
16197
|
17989
|
17990
|
17991
|
17992
|
18366
|
18367
|
18368
|
18370
|
18371
|
18642
|
18643
|
23305
|
43252
|
43253
|
43298
|
43592
|
43685
|
43686
|
43688
|
43689
|
43745
|
43746
|
43747
|
43781
|
43782
|
43783
|
43784
|
46157