Lines 27-33
use C4::Overdues qw(UpdateFine);
Link Here
|
27 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
28 |
use Koha::Database; |
28 |
use Koha::Database; |
29 |
|
29 |
|
30 |
use Test::More tests => 61; |
30 |
use Test::More tests => 65; |
31 |
|
31 |
|
32 |
BEGIN { |
32 |
BEGIN { |
33 |
use_ok('C4::Circulation'); |
33 |
use_ok('C4::Circulation'); |
Lines 37-44
my $dbh = C4::Context->dbh;
Link Here
|
37 |
my $schema = Koha::Database->new()->schema(); |
37 |
my $schema = Koha::Database->new()->schema(); |
38 |
|
38 |
|
39 |
# Start transaction |
39 |
# Start transaction |
40 |
$dbh->{AutoCommit} = 0; |
|
|
41 |
$dbh->{RaiseError} = 1; |
40 |
$dbh->{RaiseError} = 1; |
|
|
41 |
$schema->storage->txn_begin(); |
42 |
|
42 |
|
43 |
# Start with a clean slate |
43 |
# Start with a clean slate |
44 |
$dbh->do('DELETE FROM issues'); |
44 |
$dbh->do('DELETE FROM issues'); |
Lines 593-598
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
593 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
593 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
594 |
} |
594 |
} |
595 |
|
595 |
|
596 |
$dbh->rollback; |
596 |
{ |
|
|
597 |
$dbh->do('DELETE FROM issues'); |
598 |
$dbh->do('DELETE FROM items'); |
599 |
$dbh->do('DELETE FROM issuingrules'); |
600 |
$dbh->do( |
601 |
q{ |
602 |
INSERT INTO issuingrules ( categorycode, branchcode, itemtype, reservesallowed, maxissueqty, issuelength, lengthunit, renewalsallowed, renewalperiod, |
603 |
norenewalbefore, auto_renew, fine, chargeperiod ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) |
604 |
}, |
605 |
{}, |
606 |
'*', '*', '*', 25, |
607 |
20, 14, 'days', |
608 |
1, 7, |
609 |
'', 0, |
610 |
.10, 1 |
611 |
); |
612 |
my $biblio = MARC::Record->new(); |
613 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
614 |
|
615 |
my $barcode1 = '1234'; |
616 |
my ( undef, undef, $itemnumber1 ) = AddItem( |
617 |
{ |
618 |
homebranch => 'MPL', |
619 |
holdingbranch => 'MPL', |
620 |
barcode => $barcode1, |
621 |
}, |
622 |
$biblionumber |
623 |
); |
624 |
my $barcode2 = '4321'; |
625 |
my ( undef, undef, $itemnumber2 ) = AddItem( |
626 |
{ |
627 |
homebranch => 'MPL', |
628 |
holdingbranch => 'MPL', |
629 |
barcode => $barcode2, |
630 |
}, |
631 |
$biblionumber |
632 |
); |
633 |
|
634 |
my $borrowernumber1 = AddMember( |
635 |
firstname => 'Kyle', |
636 |
surname => 'Hall', |
637 |
categorycode => 'S', |
638 |
branchcode => 'MPL', |
639 |
); |
640 |
my $borrowernumber2 = AddMember( |
641 |
firstname => 'Chelsea', |
642 |
surname => 'Hall', |
643 |
categorycode => 'S', |
644 |
branchcode => 'MPL', |
645 |
); |
646 |
|
647 |
my $borrower1 = GetMember( borrowernumber => $borrowernumber1 ); |
648 |
my $borrower2 = GetMember( borrowernumber => $borrowernumber2 ); |
649 |
|
650 |
my $issue = AddIssue( $borrower1, $barcode1 ); |
651 |
|
652 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
653 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
654 |
|
655 |
AddReserve( |
656 |
'MPL', $borrowernumber2, $biblionumber, |
657 |
'a', '', 1, undef, undef, '', |
658 |
undef, undef, undef |
659 |
); |
660 |
|
661 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
662 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record' ); |
663 |
|
664 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
665 |
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
666 |
|
667 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
668 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled' ); |
669 |
|
670 |
# Setting item not checked out to be not for loan but holdable |
671 |
ModItem({ notforloan => -1 }, $biblionumber, $itemnumber2); |
672 |
|
673 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
674 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); |
675 |
} |
597 |
|
676 |
|
|
|
677 |
$schema->storage->txn_rollback(); |
598 |
1; |
678 |
1; |
599 |
- |
|
|