Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 48; |
21 |
use Test::More tests => 49; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
Lines 1578-1583
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1578 |
is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); |
1578 |
is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); |
1579 |
} |
1579 |
} |
1580 |
|
1580 |
|
|
|
1581 |
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub { |
1582 |
plan tests => 3; |
1583 |
|
1584 |
$dbh->do('DELETE FROM issues'); |
1585 |
$dbh->do('DELETE FROM items'); |
1586 |
$dbh->do('DELETE FROM circulation_rules'); |
1587 |
Koha::CirculationRules->set_rules( |
1588 |
{ |
1589 |
categorycode => undef, |
1590 |
itemtype => undef, |
1591 |
branchcode => undef, |
1592 |
rules => { |
1593 |
reservesallowed => 25, |
1594 |
issuelength => 14, |
1595 |
lengthunit => 'days', |
1596 |
renewalsallowed => 1, |
1597 |
renewalperiod => 7, |
1598 |
norenewalbefore => undef, |
1599 |
auto_renew => 0, |
1600 |
fine => .10, |
1601 |
chargeperiod => 1, |
1602 |
maxissueqty => 20, |
1603 |
onshelfholds => 1, |
1604 |
} |
1605 |
} |
1606 |
); |
1607 |
my $biblio = $builder->build_sample_biblio(); |
1608 |
|
1609 |
my $item_1 = $builder->build_sample_item({ |
1610 |
biblionumber => $biblio->biblionumber, |
1611 |
library => $library2->{branchcode}, |
1612 |
itype => $itemtype, |
1613 |
}); |
1614 |
# add second item with different branchcode |
1615 |
my $item_2 = $builder->build_sample_item({ |
1616 |
biblionumber => $biblio->biblionumber, |
1617 |
library => $library->{branchcode}, |
1618 |
itype => $itemtype, |
1619 |
}); |
1620 |
|
1621 |
my $borrowernumber1 = Koha::Patron->new({ |
1622 |
firstname => 'Kyle', |
1623 |
surname => 'Hall', |
1624 |
categorycode => $patron_category->{categorycode}, |
1625 |
branchcode => $library2->{branchcode}, |
1626 |
})->store->borrowernumber; |
1627 |
my $borrowernumber2 = Koha::Patron->new({ |
1628 |
firstname => 'Chelsea', |
1629 |
surname => 'Hall', |
1630 |
categorycode => $patron_category->{categorycode}, |
1631 |
branchcode => $library2->{branchcode}, |
1632 |
})->store->borrowernumber; |
1633 |
|
1634 |
my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; |
1635 |
my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; |
1636 |
|
1637 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
1638 |
|
1639 |
# place bib-level reserve |
1640 |
AddReserve({ |
1641 |
branchcode => $library2->{branchcode}, |
1642 |
borrowernumber => $borrowernumber2, |
1643 |
biblionumber => $biblio->biblionumber, |
1644 |
priority => 1, |
1645 |
}); |
1646 |
|
1647 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
1648 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' ); |
1649 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1650 |
is( $renewokay, 1, 'Renewal allowed if items available at any branch' ); |
1651 |
|
1652 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' ); |
1653 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1654 |
is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' ); |
1655 |
|
1656 |
# adjust 2nd item to have same branchcode |
1657 |
$item_2->update({ homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} })->store; |
1658 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); |
1659 |
is( $renewokay, 1, 'Renewal allowed if items available at hold branch' ); |
1660 |
}; |
1661 |
|
1581 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
1662 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
1582 |
plan tests => 24; |
1663 |
plan tests => 24; |
1583 |
|
1664 |
|
1584 |
- |
|
|