Bugzilla – Attachment 52908 Details for
Bug 15561
Add ability to charge cancellation fee from "Holds over" tab
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15561 [QA Followup] - Add unit tests
Bug-15561-QA-Followup---Add-unit-tests.patch (text/plain), 3.77 KB, created by
Kyle M Hall (khall)
on 2016-06-27 17:29:01 UTC
(
hide
)
Description:
Bug 15561 [QA Followup] - Add unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-27 17:29:01 UTC
Size:
3.77 KB
patch
obsolete
>From 8736644ae0b78896632bb7343442ef0e3f7bd9ac Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 27 Jun 2016 17:27:35 +0000 >Subject: [PATCH] Bug 15561 [QA Followup] - Add unit tests > >--- > t/db_dependent/Holds/CancelAll.t | 123 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 123 insertions(+) > create mode 100755 t/db_dependent/Holds/CancelAll.t > >diff --git a/t/db_dependent/Holds/CancelAll.t b/t/db_dependent/Holds/CancelAll.t >new file mode 100755 >index 0000000..2a75627 >--- /dev/null >+++ b/t/db_dependent/Holds/CancelAll.t >@@ -0,0 +1,123 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use Test::More tests => 7; >+ >+use MARC::Record; >+ >+use C4::Context; >+use C4::Branch; >+use C4::Biblio; >+use C4::Items; >+use C4::Members; >+use Koha::Database; >+use Koha::Holds; >+use Koha::Account::Lines; >+ >+BEGIN { >+ use FindBin; >+ use lib $FindBin::Bin; >+ use_ok('C4::Reserves'); >+} >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+my $dbh = C4::Context->dbh; >+ >+# Create two random branchcodees >+my $category = $builder->build( { source => 'Category' } ); >+my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >+ >+my $borrowers_count = 2; >+ >+my ( $biblionumber, $title, $biblioitemnumber ) = create_helper_biblio('DUMMY'); >+ >+C4::Context->set_preference( 'ExpireReservesMaxPickUpDelayCharge', '5.00' ); >+ >+my ( undef, undef, $itemnumber ) = AddItem( >+ { >+ homebranchcode => $branchcode, >+ holdingbranchcode => $branchcode >+ }, >+ $biblionumber >+); >+ >+my $borrowernumber = AddMember( >+ firstname => 'my firstname', >+ surname => 'my surname ' . $_, >+ categorycode => $category->{categorycode}, >+ branchcode => $branchcode, >+); >+ >+my $id = AddReserve( >+ $branchcode, >+ $borrowernumber, >+ $biblionumber, >+ my $bibitems = q{}, >+ my $priority = C4::Reserves::CalculatePriority($biblionumber), >+ my $resdate, >+ my $expdate, >+ my $notes = q{}, >+ $title, >+ my $checkitem = $itemnumber, >+ my $found, >+); >+ >+my $hold = Koha::Holds->find($id); >+is( $hold->id, $id, 'Hold created correctly.' ); >+ >+$dbh->do("DELETE FROM accountlines"); >+ >+# Cancel with no cancelation fee >+ModReserveCancelAll( $itemnumber, $borrowernumber ); >+ >+$hold = Koha::Holds->find( $id ); >+is( $hold, undef, 'Hold canceled correctly' ); >+ >+my $accountlines = >+ Koha::Account::Lines->search( { borrowernumber => $borrowernumber } ); >+is( $accountlines->count(), 0, "No charge created for cancelation" ); >+ >+$id = AddReserve( >+ $branchcode, >+ $borrowernumber, >+ $biblionumber, >+ $bibitems = q{}, >+ $priority = C4::Reserves::CalculatePriority($biblionumber), >+ $resdate, >+ $expdate, >+ $notes = q{}, >+ $title, >+ $checkitem = $itemnumber, >+ $found, >+); >+ >+# Cancel with cancelation fee >+ModReserveCancelAll( $itemnumber, $borrowernumber, 1 ); >+ >+$hold = Koha::Holds->find( $id ); >+is( $hold, undef, 'Hold canceled correctly' ); >+ >+$accountlines = >+ Koha::Account::Lines->search( { borrowernumber => $borrowernumber } ); >+is( $accountlines->count(), 1, "Found charge for cancelation" ); >+is( $accountlines->as_list->[0]->amountoutstanding, '5.000000', 'Charge is equal to ExpireReservesMaxPickUpDelayCharge' ); >+ >+# Helper method to set up a Biblio. >+sub create_helper_biblio { >+ my $itemtype = shift; >+ my $bib = MARC::Record->new(); >+ my $title = 'Silence in the library'; >+ $bib->append_fields( >+ MARC::Field->new( '100', ' ', ' ', a => 'Moffat, Steven' ), >+ MARC::Field->new( '245', ' ', ' ', a => $title ), >+ MARC::Field->new( '942', ' ', ' ', c => $itemtype ), >+ ); >+ return ( $biblionumber, $title, $biblioitemnumber ) = AddBiblio( $bib, '' ); >+} >-- >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 15561
:
46558
|
50325
|
51742
|
52906
|
52907
|
52908
|
53724
|
63358
|
63359
|
63360
|
63361
|
81904
|
81905
|
81906
|
81907