Bugzilla – Attachment 77758 Details for
Bug 21196
C4::Overdues::CalcFine should consider default item type replacement cost
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21196: Add tests
Bug-21196-Add-tests.patch (text/plain), 2.58 KB, created by
Jonathan Druart
on 2018-08-13 15:43:00 UTC
(
hide
)
Description:
Bug 21196: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-08-13 15:43:00 UTC
Size:
2.58 KB
patch
obsolete
>From f6145a7f6f895ee05970480133ddf949c5dca585 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 13 Aug 2018 12:36:41 -0300 >Subject: [PATCH] Bug 21196: Add tests > >--- > t/db_dependent/Circulation/CalcFine.t | 31 ++++++++++++++++++++++++++----- > 1 file changed, 26 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t >index 862673f53d..24cf5800b7 100644 >--- a/t/db_dependent/Circulation/CalcFine.t >+++ b/t/db_dependent/Circulation/CalcFine.t >@@ -12,12 +12,14 @@ 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; >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; > >+our $dbh = C4::Context->dbh; > $dbh->do(q|DELETE FROM issues|); > >+t::lib::Mocks::mock_preference('item-level_itypes', '1'); >+ > my $builder = t::lib::TestBuilder->new(); > > my $branch = $builder->build( >@@ -51,6 +53,15 @@ my $biblio = $builder->build( > } > ); > >+my $itemtype = $builder->build( >+ { >+ source => 'Itemtype', >+ value => { >+ defaultreplacecost => 6, >+ }, >+ } >+); >+ > my $item = $builder->build( > { > source => 'Item', >@@ -59,6 +70,7 @@ my $item = $builder->build( > homebranch => $branch->{branchcode}, > holdingbranch => $branch->{branchcode}, > replacementprice => '5.00', >+ itype => $itemtype->{itemtype}, > }, > } > ); >@@ -110,7 +122,9 @@ subtest 'Test basic functionality' => sub { > }; > > subtest 'Test cap_fine_to_replacement_price' => sub { >- plan tests => 1; >+ plan tests => 2; >+ >+ t::lib::Mocks::mock_preference('useDefaultReplacementCost', '1'); > my $issuingrule = $builder->build( > { > source => 'Issuingrule', >@@ -143,7 +157,14 @@ subtest 'Test cap_fine_to_replacement_price' => sub { > > my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); > >- is( $amount, '5.00', 'Amount is calculated correctly' ); >+ is( int($amount), 5, 'Amount is calculated correctly' ); >+ >+ >+ # Use default replacement cost (useDefaultReplacementCost) is item's replacement price is 0 >+ my $item_obj = Koha::Items->find($item->{itemnumber}); >+ $item_obj->replacementprice(0)->store; >+ ($amount) = CalcFine( $item_obj->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ is( int($amount), 6, 'Amount is calculated correctly' ); > > teardown(); > }; >-- >2.11.0
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 21196
:
77758
|
77759
|
79340
|
79341