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 => 69; |
21 |
use Test::More tests => 70; |
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 1690-1695
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1690 |
$recall->set_cancelled; |
1690 |
$recall->set_cancelled; |
1691 |
}; |
1691 |
}; |
1692 |
|
1692 |
|
|
|
1693 |
subtest "CanBookBeRenewed | bookings" => sub { |
1694 |
plan tests => 3; |
1695 |
|
1696 |
my $schema = Koha::Database->schema; |
1697 |
$schema->storage->txn_begin; |
1698 |
|
1699 |
t::lib::Mocks::mock_preference('RenewalPeriodBase', 'date_due'); |
1700 |
|
1701 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1702 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1703 |
my $item = $builder->build_sample_item( { bookable => 1 } ); |
1704 |
|
1705 |
# issue |
1706 |
my $issue = AddIssue( $renewing_patron, $item->barcode ); |
1707 |
my $datedue = dt_from_string( $issue->date_due() ); |
1708 |
is( defined $issue->date_due(), 1, "Item checked out, due date: " . $issue->date_due() ); |
1709 |
|
1710 |
# item-level booking |
1711 |
my $booking = Koha::Booking->new( |
1712 |
{ |
1713 |
patron_id => $booked_patron->borrowernumber, |
1714 |
item_id => $item->itemnumber, |
1715 |
biblio_id => $item->biblio->biblionumber, |
1716 |
start_date => $datedue->clone()->add( days => 2 ), |
1717 |
end_date => $datedue->clone()->add( days => 10 ), |
1718 |
} |
1719 |
)->store(); |
1720 |
|
1721 |
# Proposed renewal would encroach on booking |
1722 |
my ( $renewok, $error ) = CanBookBeRenewed( $renewing_patron, $issue, 0 ); |
1723 |
is( $renewok, 0, "Renewal not allowed as it would mean the item was not returned before the next booking" ); |
1724 |
is( $error, 'booked', "Error is 'booked'" ); |
1725 |
|
1726 |
$schema->storage->txn_rollback; |
1727 |
}; |
1728 |
|
1693 |
subtest "GetUpcomingDueIssues" => sub { |
1729 |
subtest "GetUpcomingDueIssues" => sub { |
1694 |
plan tests => 12; |
1730 |
plan tests => 12; |
1695 |
|
1731 |
|
1696 |
- |
|
|